Question: 22. Suppose s and t are two semaphores initialized with init(s) and init(t). Consider the following code fragment of two concurrent processes: * (a) Does

22. Suppose s and t are two semaphores initialized with init(s) and init(t). Consider the following code fragment of two concurrent processes:

Process P1 Process P2 wait(s); wait(t); wait(t); wait(s); critical section critical section

*

(a) Does the algorithm guarantee mutual exclusion? If not, show an execution sequence that lets both processes run in their critical sections simultaneously.

(b) Does the algorithm prevent deadlock? If not, show an execution sequence that deadlocks P1 and P2.

Process P1 Process P2 wait(s); wait(t); wait(t); wait(s); critical section critical section signal(s); signal(t); signal(t); signal(s); remainder section remainder section

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Principles Algorithms And Systems Questions!