CS FundamentalsVery hardGATE CS (PYQ pattern)
A bounded buffer has 3 slots: empty = 3, full = 0, mutex = 1 (classic implementation where a blocked wait leaves the semaphore negative). Five producers each try to insert one item and all five run before any consumer. Afterwards two consumers each remove one item, and every blocked producer woken completes its insertion. What are the final values of (empty, full) once everything settles?
- A. (0, 3)
- B. (1, 2)
- C. (2, 1)
- D. (-2, 5)
Correct answer: A. (0, 3)
Five producers: three succeed (empty 0, full 3) and two block (empty = -2). Each consumer does wait(full) then signal(empty), waking a blocked producer who then signals full again: after both, empty = 0, full = 3 (3 items in the buffer).
More Operating Systems questions
- Each of 8 processes P0..P7 waits for at most one other process (single-instance resources). The wait-for relation is: P0 waits for P1, P1…
- Single resource type, 5 processes. Allocation: 2, 2, 0, 1, 4. Maximum: 3, 3, 8, 2, 6. Available = 3. The state is safe. What is the…
- Semaphores s = 1, t = 0. P1: wait(s); print A; print B; signal(s). P2: wait(s); print C; signal(s). P3: wait(t); print D; signal(s). P4…
- Semaphores a = 1, b = 0, c = 0. P1: wait(a); print x; signal(b). P2: wait(b); print y; signal(c). P3: wait(c); print z; signal(a). P4…
- Round Robin with quantum 4 ms; processes (arrival, burst) in ms: A (0, 11), B (2, 6), C (3, 3), D (5, 9), E (8, 2). A process that arrives…
- The head is at cylinder 50. Pending requests in arrival order: 82, 170, 43, 140, 24, 16, 190. By how many cylinders is the total head…