A counting semaphore was initialized to 7. Then 20 P (wait) operations and x V (signal) operations were completed on this semaphore. If the final value of semaphore is 5, then the value x will be

Options

  • A. 5
  • B. 7
  • C. 18
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 18

Detailed Explanation

A semaphore follows this formula:

Given:

Initial value = 7

P (wait) operations = 20

V (signal) operations =

Final value = 5