1,624 views
3 votes
3 votes

the following five concurrent processes operating on counting semaphore variable (s) which is initialized to 0

P1: wait (s); cs; signal (s);

P2: wait (s); cs; signal (s);

P3: wait (s); cs; signal (s);

P4: signal s); cs; wait (s);

P5: signal (s); cs; wait (s);

what is the maximum possible value of s?

A) 1 B) 2 C) 3 D) 0

2 Answers

Best answer
8 votes
8 votes
P4 and P5 can do signal operation without any intermediate wait and thus s can go up to value 2.
selected by
0 votes
0 votes
Execute first 3 fully and last 2 only till critical section. So value of S becomes 2 which is the maximum possible.

Related questions

0 votes
0 votes
1 answer
1
N3314nch41 asked Sep 10, 2023
359 views
How to approach synchronization (specifically semaphore) question, there size are really intimidating and i’m unable to decode the code written? What to do??