At a particular time of computation, the value of a counting semaphore is 7. Then 20 P operations and 'x' V operations were performed on this semaphore. If the final value of the semaphore is 5, what is x?
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: C. 18
Explanation
Each P (wait) operation decrements a counting semaphore by 1 and each V (signal) operation increments it by 1, so the final value equals the initial value minus the number of P operations plus the number of V operations: 7 − 20 + x = 5. Solving gives x = 5 − 7 + 20 = 18, option (iii). The semaphore's value dipping below zero during the sequence is normal for a counting semaphore (it then represents the number of processes queued and waiting) and does not affect this final arithmetic.More System Software and Operating System questions
- At a particular time of computation, the value of a counting semaphore is 7. Then 20 P operations and 'x' V operations were performed on th…
- Consider a system with five processes P0 through P4 and three resource types A, B and C, with 7, 2 and 6 total instances respectively. At t…
- The Bounded Buffer problem is also known as the ________.
- Two atomic operations permissible on semaphores are ________ and ________.
- Three processes share a single counting semaphore S whose initial value is 1. All three execute wait(S) one after another, in the order P2,…
- In the UNIX operating system, when a process creates a child process using the fork() system call, which of the following is genuinely shar…