CS FundamentalsVery hardProduct company interview · GATE level
A system with resource types A, B, C (several instances each) runs the deadlock-detection algorithm. Allocation: P0 (0,1,0), P1 (2,0,0), P2 (3,0,3), P3 (2,1,1), P4 (0,0,2). Current requests: P0 (0,0,0), P1 (2,0,2), P2 (0,0,1), P3 (1,0,0), P4 (0,0,2). Which processes are deadlocked if Available is (0,0,0), and which if Available is (0,0,1)?
- A. (0,0,0): P1, P2, P3 and P4; (0,0,1): none
- B. (0,0,0): none; (0,0,1): none
- C. (0,0,0): P1, P2, P3 and P4; (0,0,1): P1 only
- D. (0,0,0): P1 and P2 only; (0,0,1): none
Correct answer: A. (0,0,0): P1, P2, P3 and P4; (0,0,1): none
Detection treats current requests like needs. With (0,0,0) only P0 (requesting nothing) can finish; it returns (0,1,0), which satisfies none of the others, so P1-P4 are deadlocked. With (0,0,1), P0 finishes (work (0,1,1)), then P2 (request (0,0,1)) finishes and returns (3,0,3) for (3,1,4); now P3 and P4 finish, and finally P1 (2,0,2). One spare instance of C breaks the whole deadlock, so stopping after the first pass and declaring P1 deadlocked is wrong.
More Operating Systems questions
- Shared int x = 1. Thread T1 executes x = x + 1; twice; thread T2 executes x = x 2; once. Each statement compiles to a load of x into a…
- Semaphores a = 0 and b = 0. Three processes run concurrently: P: print('A'); signal(a); wait(b); print('B'); Q: wait(a); print('C')…
- Two processes (i = 0, 1; j = 1 - i) share bool flag[2] = {false, false} and int turn, and each runs entry code, then its critical section…
- How many lines print the value 3, and what is the sum of all the values printed? (Assume every fork() succeeds.) c int main() { int c = 0…
- A buddy allocator manages 1024 KB and splits blocks in powers of two, always using the lowest-addressed free block of the needed size…
- A disk has cylinders 0-499. The head is at 237 and is moving towards cylinder 0. Pending requests: 312, 45, 401, 198, 260, 12, 477, 150…