Question: Two threads, A and B, execute a procedure named glorp but always at different times (that is, only one of the threads calls the procedure
Two threads, A and B, execute a procedure named glorp but always at different times (that is, only one of the threads calls the procedure at a given time). glorp contains the following code:

a. Assuming that no other code in other procedures ever acquires more than one lock at a time, can there be a deadlock? (If yes, give an example; if not, argue why not.)
b. Now, assuming that the two threads can be in the code fragment above at the same time, can the program deadlock? (If yes, give an example; if not, argue why not.)
procedure GLORP () ACQUIRE (lock_a) ACQUIRE (lock_b) RELEASE (lock_b) RELEASE (lock_a) ACQUIRE (lock_b) ACQUIRE (lock_a) RELEASE (lock_a) RELEASE (lock_b)
Step by Step Solution
3.45 Rating (164 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
