Question on Semaphores


#1

Counting semaphore block queue contain 20 processes at a specific time,
later 10 down() operations and P up() operations were performed on this
semaphore. If the new value of semaphore is 45, find the value of P.


#2

Since 20 processes are blocked so let us assume the semaphore(S) = -20;
Now performing 10 down operations will result in S = S - 10 = -20 - 10 = -30.
So if the value of S1 = 45 => S1 = S + P => 45 = -30 + P => P = 45 + 30 => P = 75