Question: In the code below, three processes are competing for six resources labeled A to F. a. Determine a sequence of requests and locks that results
In the code below, three processes are competing for six resources labeled A to F. a. Determine a sequence of requests and locks that results in a deadlock among the 3 processes. You could, for example, for each process list which resources it currently has locked (Allocated) and which resource it is requesting. Hint: it might be useful to draw a resource allocation graph to help you find a deadlock. b. Modify the order of some of the get requests to prevent the possibility of any deadlock. You cannot move requests to another process, only change the order inside each one. void P0() { while (true) { get(A); get(B); get(C); // critical region: // use A, B, C release(A); release(B); release(C); } } void P1() { while (true) { get(D); get(E); get(B); // critical region: // use D, E, B release(D); release(E); release(B); } } void P2() { while (true) { get(C); get(F); get(D); // critical region: // use C, F, D release(C); release(F); release(D); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
