In context of semaphores choose the option with valid codes for wait() and…
2022
In context of semaphores choose the option with valid codes for wait() and signal() functions:
- A.
Wait (s) { while (s) <= 0; s + + } and signal (s) { s - -; }
- B.
Wait (s) { while (s) <= 0; s - - } and signal (s) { s + +; }
- C.
Wait (s) { s - -; } and signal (s) { while (s) <= 0; s + + }
- D.
Wait (s) { s + +; } and signal (s) { while (s) <= 0; s - -; }
Attempted by 79 students.
Show answer & explanation
Correct answer: B
A Semaphore is a synchronization tool used in operating systems to control access to shared resources.
The standard semaphore operations are:
Meaning:
wait() / P() operation
Checks whether a resource is available.
If not available, the process waits.
When available, it decreases the semaphore value.
signal() / V() operation
Releases the resource.
Increases the semaphore value.