September 17th, 2003, 12:40 AM
Critical section and Deadlock
Can any one tell me the following:
1. how to create 3 processes that enter and leave a Critical Section.\
2. How to make 3 processes deadlock.
September 17th, 2003, 02:05 AM
how to make 3 processes enter/leave crit section:
place a critical section in each one! no really that's all. critical sections dont span processes, only threads. a mutex is what you need to use. google for 'mutexes', not sure if your on windows/linux or not....
how to make 3 processes deadlock:
google for race condition. basicallly you could have 3 process sharing 3 resources. each process is sharing 2 resources, one with one process and one with another. in order to achieve its goal, a process has to lock into both of its available resources. if there is not proper synchronization on the testing of resource availability it may happen that each thread grabs a different available resource at the exact same time, thus causing all resources to be tied up, but no work can be accomplished b/c they only have one each. thus they are "frozen" / "deadlocked". there would be other ways to deadlock processes as well if your dealing with fifo's, etc.. google on race conditions, starvation, denial of service