CS FundamentalsHardIBM · Deloitte pattern
How many of the following statements about semaphores and mutexes are correct? 1. A binary semaphore can be used to achieve mutual exclusion. 2. A mutex can be released only by the thread that acquired it, whereas a semaphore can be signalled by any thread. 3. A counting semaphore initialised to 3 lets at most 3 threads into the guarded section at once. 4. wait() and signal() must themselves execute atomically.
- A. Only one
- B. Only two
- C. Only three
- D. All four
Correct answer: D. All four
All four hold. Ownership (2) is the key difference that makes a mutex suitable for locking and a semaphore suitable for signalling between threads; atomicity (4) is what makes either work.
More Operating Systems questions
- Process L (low priority) holds a lock that high-priority process H needs. Medium-priority process M, which does not need the lock, becomes…
- Consider this loop: c for (int i = 0; i < 2; i++) { fork(); printf("-"); } stdout is redirected to a file (fully buffered) and no fflush…
- Which CPU scheduling algorithm can make a long process wait indefinitely if short processes keep arriving?
- Which part of the operating system selects which process in the ready queue gets the CPU next?
- Processes (arrival, burst): P1 (0, 4), P2 (1, 3), P3 (2, 6), P4 (4, 2). What is the average turnaround time under FCFS?
- Reference string: 1, 3, 0, 3, 5, 6, 3, 1, 0, 6, 5, 3. With 3 frames, initially empty, how many page faults does FIFO replacement cause?