CS FundamentalsHardProduct-company MCQ pattern
Five processes P0–P4 and three resource types A, B, C. Allocation: P0 (1,0,1), P1 (2,1,1), P2 (0,1,2), P3 (1,1,0), P4 (0,0,2). Max: P0 (4,2,3), P1 (3,2,2), P2 (2,3,4), P3 (3,1,2), P4 (1,2,3). Available: (1,1,1). P4 now requests (0, 0, 1). What should the Banker's algorithm do?
- A. Make P4 wait, because the resulting state would be unsafe
- B. Grant it, and the safe sequence becomes P4, P1, P3, P0, P2
- C. Grant it, since the request ≤ Need and ≤ Available
- D. Abort P4, because the request exceeds its maximum claim
Correct answer: A. Make P4 wait, because the resulting state would be unsafe
The request passes both checks (≤ Need (1,2,1), ≤ Available (1,1,1)). Pretending to grant it: Available = (1,1,0), P4's need = (1,2,0). Now P1 needs (1,1,1), but C = 0, and nobody else fits either, so the state is unsafe and P4 must wait. Passing the two checks is not enough.
More Operating Systems questions
- A system has 6 identical tape drives. Each of n processes needs at most 2 drives. What is the maximum n for which the system is guaranteed…
- How many of the following statements about deadlock are correct? 1. Requiring a process to request all its resources at once prevents…
- Semaphores S = 1 and T = 0. Process X runs: wait(S); print('A'); signal(T); Process Y runs: wait(T); print('B'); signal(S); Each runs its…
- Two threads each run the loop for (i = 0; i < 5; i++) count++; on a shared int count = 0, with no synchronisation. count++ is compiled to…
- How many times is "x" printed? (fork() returns 0 in the child and a positive PID in the parent; assume it always succeeds.) c int main() {…
- How many times is "x" printed? (Assume every fork() succeeds.) c int main() { fork(); fork() || fork(); printf("xn"); return 0; }