I need to detect a deadlock by adding some code to the process's main function or inside his handler (HandleEvent()) using only: NewThread, Semaphore, GetMessage, Write2memory, ReadFromMemory.
There are 5 processes with there priority:
processes: t1 t2 t3 t4 t5
priority: 2 3 4 5 6
lets say that every process main function looks something like:
GetEvent(event e); //get event from the event's queue.
HandleEvent(event e); //treat the event and handle it.
There is a budget of 10 second for all the 5 processes. In other words, we are sure that all 5 processes got CPU's time during 10 sec. If 10 second passed and 2 or more of the processes didn't handle their events, that means they got stuck and they are in "deadlock" position. We want to add some code that eventually we get a message that says "Process X in deadlock". We want to know that when this happens.
This should be Real-Time in C programming. The solution should be easy and simple, but I haven't found it yet.. Please guys, tell me what you think.. Thanks in advance.