Problem on counting Semaphore

Question
A counting semaphore = 10 and then 6 P and 4 v are made then what is the value of semaphore ?
Answer
10 – 6 = 4 and then 4 v will increment the semaphore value as 4 + 4 which is 8.

Properties of Counting Semaphore

  1. Increment/Decrement of semaphore value will be atomic.
  2. There is no mutual exclusion as >1 processes can enter into critical section.
  3. Bounded waiting will be guaranteed as wake up will happen in same order in which they slept.
  4. Progress is also there as no one will prevent other process if the former does not want critical section.





Quantitative Aptitude
Reasoning
Programming
Interview