CS FundamentalsEasyGATE CS (PYQ pattern)
A one-slot buffer uses semaphores mutex = 1, empty = 1, full = 0. The producer runs twice: wait(mutex); wait(empty); print p; signal(full); signal(mutex). The consumer runs twice: wait(full); wait(mutex); print c; signal(empty); signal(mutex). They start together. Which statement is correct?
- A. No deadlock is possible, and the only complete output is pcpc
- B. A deadlock is possible, and the only complete output is pcpc
- C. A deadlock is possible, and both pcpc and ppcc are complete outputs
- D. No deadlock is possible, and the outputs pcpc and cpcp are both possible
Correct answer: B. A deadlock is possible, and the only complete output is pcpc
In the second iteration the producer can take mutex and then block on empty (the slot is still full), while the consumer, holding full, blocks on mutex: deadlock. In all completing runs the one-slot buffer forces strict alternation p c p c.
More Operating Systems questions
- Five processes with CPU bursts 5, 12, 3, 9 and 7 ms all arrive at time 0 in that order. Context switches are free. Among the quanta 2, 4…
- A 32-bit machine uses two-level paging with 10 + 10 + 12 address bits. For the running process, root-table entries 3 and 0x2FF are valid…
- Assume every fork() succeeds and output is not lost or duplicated. int x = 1; int main(void) { int p = &x; if (fork() == 0) { p += 2; if…
- Three periodic tasks (execution time, period = relative deadline), all released at t = 0: T1 (2, 6), T2 (3, 8), T3 (3, 12). They are…
- Which of the following statements about system calls and interrupts are correct? I. A system call enters the kernel through a trap…
- Which of the following statements about disk scheduling are correct? I. SSTF can starve requests far from the head. II. SCAN bounds the…