CS FundamentalsModerateGATE CS
A semaphore S starts at 7. Over time 20 wait() and 15 signal() operations complete on it, in some order, with no process left blocked at the end. What is the final value of S?
- A. 2
- B. 0
- C. 12
- D. −2
Correct answer: A. 2
Each completed wait subtracts 1 and each signal adds 1: 7 − 20 + 15 = 2. Since nobody is left blocked, every wait did complete, so the value is simply the net count.
More Operating Systems questions
- A Unix process opens a file, forks, and both parent and child each write 100 bytes to the inherited descriptor (no OAPPEND, no seeks), one…
- Which statement about the convoy effect is correct?
- Disk cylinders 0–199; the head is at 120 moving toward 199; requests: 10, 22, 20, 2, 40, 6, 38. Counting the return jump as head movement…
- Which property of a journaling file system's ordered mode is correct?
- A process's address space uses three-level paging with 9 bits per level and 4 KB pages (8-byte entries, so each table is one 4 KB page)…
- A CPU-bound process and an I/O-bound process share a single CPU under a multilevel feedback queue with priority boosting. What is the…