Q.No.3. During online class we studied that, if the semaphore operations Wait and Signal are not executed atomically, then mutual exclusion may be violated. Assume that Wait and Signal are implemented...


Q.No.3.<br>During online class we studied that, if the semaphore operations Wait and Signal are not executed<br>atomically, then mutual exclusion may be violated. Assume that Wait and Signal are implemented as<br>below:<br>void Wait (Semaphore s) {<br>while (S.count <= 0) {}<br>s.count = s.count - 1;<br>void Signal (Semaphore S) {<br>S.count = S.count + 1;<br>Code: (a)<br>a) Build a scenario of context switches that includes two threads and permit to enter a critical section<br>secured by a single mutex semaphore as a result of a lack of atomicity.<br>wait(S) = {while S < 0; S--; }<br>signal(S) = {S++; }<br>Code: (b)<br>b) Assume, S=1, P & Q protects a critical region with the semaphore S. Show that if one of these<br>operations is not executed atomically, we may violate mutual exclusion.<br>

Extracted text: Q.No.3. During online class we studied that, if the semaphore operations Wait and Signal are not executed atomically, then mutual exclusion may be violated. Assume that Wait and Signal are implemented as below: void Wait (Semaphore s) { while (S.count <= 0)="" {}="" s.count="s.count" -="" 1;="" void="" signal="" (semaphore="" s)="" {="" s.count="S.count" +="" 1;="" code:="" (a)="" a)="" build="" a="" scenario="" of="" context="" switches="" that="" includes="" two="" threads="" and="" permit="" to="" enter="" a="" critical="" section="" secured="" by="" a="" single="" mutex="" semaphore="" as="" a="" result="" of="" a="" lack="" of="" atomicity.="" wait(s)="{while" s="">< 0;="" s--;="" }="" signal(s)="{S++;" }="" code:="" (b)="" b)="" assume,="" s="1," p="" &="" q="" protects="" a="" critical="" region="" with="" the="" semaphore="" s.="" show="" that="" if="" one="" of="" these="" operations="" is="" not="" executed="" atomically,="" we="" may="" violate="" mutual="">

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here