CS FundamentalsVery hardGATE CS (PYQ pattern)
Fixed priorities H > M > L, preemptive, one CPU. L arrives at 0: computes 2 ms, locks mutex m, computes 4 ms, unlocks, computes 1 ms. M arrives at 3 and computes 6 ms (never uses m). H arrives at 4: computes 1 ms, locks m, computes 2 ms, unlocks, computes 1 ms. At what time does H finish without priority inheritance, and with it (L inherits H's priority while H is blocked on m)?
- A. 17 ms and 11 ms
- B. 16 ms and 11 ms
- C. 16 ms and 13 ms
- D. 16 ms and 10 ms
Correct answer: B. 16 ms and 11 ms
Without inheritance: L 0-3 (locks at 2), M 3-4, H 4-5 then blocks on m, M runs 5-10, L finishes its critical section 10-13, H 13-16. With inheritance: same until 5, then L runs at H's priority 5-8 and unlocks, H runs 8-11; M only resumes at 11. M's 5 ms after H blocks is exactly the inversion that inheritance removes.
More Operating Systems questions
- A bounded buffer has 3 slots: empty = 3, full = 0, mutex = 1 (classic implementation where a blocked wait leaves the semaphore negative)…
- 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…