Semaphore - Example - Operating System

Q.  Consider a counting semaphore which was initialized to 10 and then 6P (wait) operations and 4v(signal) operations were completed on this semaphore. What is the resulting value of semaphore?
- Published on 25 Aug 15

a. 10
b. 9
c. 8
d. 0

ANSWER: 8
 

    Discussion

  • Nirja Shah   -Posted on 23 Nov 15
    - 6P => It decrements the semaphore 6 times. Hence , the value becomes 4.

    - 4V => It increments the semaphore 4 times. Hence , the value becomes 8.

    - The positive value of counting semaphore indicates that those many down (P) operations can be carried out successfully.

    - The negative value of counting semaphore indicates that the number of blocked processes.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)