Question: Implement the counting semaphores using binary semaphores. Pseudo-code for the implementation is given below. In your main(), spawn three threads; in each thread function, you
2 Implementation 1 (incorrect) CSentK) escount ing sen, init K int val K: //value of cset BSem waito): to block on csem BSem nutext1): / protects val Peics) C Evolation showing error nitial: if val 0: 0 1f val0 BSee nutex(1) If protects va Pctcs)C P(gate) al: Knutex); vval-1 if val > 0 Vgate): Pnute): val+1: f val VCgate)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
