CS FundamentalsHardGATE CS
Semaphores a = 1, b = 0. P: wait(a); print 1; signal(b); signal(b). Q: wait(b); print 2; signal(a). R: wait(b); print 3. Each runs once. Which outputs are possible?
- A. 123 only
- B. 123 and 132 only
- C. 123, 132 and 213
- D. Any permutation of 1, 2, 3
Correct answer: B. 123 and 132 only
1 must come first (only P can start); after its two signals both Q and R are released in either order: 123, 132.
More Operating Systems questions
- Shared x = 1. T1 does x = x + 1; T2 and T3 each do x = x 2; (load, compute, store, no locks). How many distinct final values of x are…
- How many of these statements about threads are correct? 1. A thread that calls exit() terminates the whole process. 2. If one thread…
- A server uses a fixed pool of 8 worker threads, and each request does a blocking database call taking 90% of its time. Roughly how many…
- Which statement about user-mode and kernel-mode stacks is correct?
- A process gets SIGSEGV writing to a page marked read-only that belongs to a copy-on-write mapping after fork(). Why is this NOT what…
- A system uses paging with a 2-bit protection field (read, write) in each PTE and the CPU also has an execute-disable bit. Which page…