CS42
main() { semaphore A = 2, B = 2, C = 3, D = 3, E = 2; cobegin { P1: { P(B,D,E); /* compute one */ P(A,C); /* compute two */ V(A,B,C,D,E); } P2: { P(C,D,E); /* compute one */ P(A,B); /* compute two */ V(A,B,C,D,E); } P3: { P(A,C); /* compute one */ P(B,D); /* compute two */ V(A,B,C,D); } P4: { P(A,B); /* compute one */ P(D,E); /* compute two */ V(A,B,D,E); } } }
The cobegin statement is used to fork child processes. Each labeled block becomes a child process of the parent. For a multisemaphore P() to proceed, all of the semaphore arguments must have values greater than zero.
Each process has completed its compute one phase and is performing the second multisemaphore P operation. Prove that this system is currently deadlocked. If you could increase by one the number of units of any of the five resources, which increase (if any) would resolve the deadlock?
Determine the order in which the requests are serviced for each of the following disk scheduling disciplines: