-操作系统精髓与设计原理(第五版)+课后题答案1
CHAPTER 6
CONCURRENCY: DEADLOCK AND
STARVATION
Review Questions
6.2 Mutual exclusion. Only one process may use a resource at a time. Hold
and wait. A process may hold allocated resources while awaiting assignment of others. No preemption. No resource can be forcibly removed from a process holding it.
6.3 The above three conditions, plus: Circular wait. A closed chain of
processes exists, such that each process holds at least one resource needed by the next process in the chain.
Problems
6.4 a. 0 0 0 0 0 7 5 0 6 6 2 2 2 0 0 2 0 3 2 0 b. to d. Running the banker's algorithm, we see processes can finish
in the order p1, p4, p5, p2, p3.
e. Change available to (2,0,0,0) and p3's row of "still needs" to (6,5,2,2).
Now p1, p4, p5 can finish, but with available now (4,6,9,8) neither p2 nor p3's "still needs" can be satisfied. So it is not safe to grant p3's request.
6.5 1. W = (2 1 0 0) 2. Mark P3; W = (2 1 0 0) + (0 1 2 0) = (2 2 2 0) 3. Mark P2; W = (2 2 2 0) + (2 0 0 1) = (4 2 2 1) 4. Mark P1; no deadlock detected