Suppose we have processes P1 and P2 as follows:monitor deadlock condition p, q; void stop(void) { p.wait; ...... q.signal; } void go(void); { ...... p.signal; q.wait; } // no initialization is required }
The intention of this monitor is that P1 is required to wait on condition p until P2 has completed some task, at which point it calls deadlock.go to release P1. P2 then waits until P1 has performed its task, when it signals condition q to indicate that P2 may continue.P1: repeat ..... deadlock.stop; ..... until false; P2: repeat ..... deadlock.go; ..... until false;
This program looks correct and seems can perform the indicated task. But, it has the potential to deadlock. Find this deadlock.
You do not have to turn in your paper. What I really expect you to do is using these problems to gauge your understanding of the subject. So, do the problems after finish reading the above sections. |