|
Instructors : Dr. Tong Lai Yu
Partial Solution to Homework 1
1) CSP problems. a) Use CSP commands to write a statement that does the following: Solution: y ≥ x → m := y]
b) Use CSP commands to write a statement that does the following: Solution:
val > 0; Y?() -> val := val - 1]
Solution: 3) ( Textbook 3.4 ) Show that the ordered request policy of Havender prevents deadlock. Solution: Let R = { R1, R2, ..., Rm } be the set of resource types
e.g.
F ( disk drive ) = 5 F ( printer ) = 12 Suppose a process first requests Ri, it can request Rj only if F(Rj) > F(Ri) We want to prove that circular-wait does not exist under this constraint and thus no deadlock can occur. Proof:
Assume the contrary that circular-wait exists and suppose
circular wait holds for
Pi is waiting for Ri which is held by Pi+1 Because Pi+1 is holding Ri while requesting Ri+1, we have
=> F( R0 ) < F( R1 ) < ... < F( Rn ) < F( R0 ) => F( R0 ) < F( R0 ) Thus circular wait does not exist. 4) Consider a computer system that has 4 identical units of resource R. There are 3 processes each with a maximum claim of 2 units of resource R. Processes can request these resources in any way, i.e. two in one shot or one by one. The system alwasy satisfies a request if the enough resources are available. If the processes don't request any other kind of resource, is deadlock possible in this system? Why? ( Show your steps clearly. ) Proof: In the worst case P = R - 1, each process holds one unit and requests another one. Since there are only R - 1 processes, the system still has one unit available to be assigned to one of the processes; the process can then finish the task and returns the two units, which can then satisfy another two pending processes and so on. Eventually, all processes can be satisfied and the system is deadlock free. 5) ( Textbook 3.7 ) Assume a system has P processes and R identical units
of a reusable resource. If each process can claim at most N units of the resource,
show that the system will be deadlock free iff R ≥ P(N - 1) + 1.
Proof is similar to 4). Actually, 4) is a special case
of 5) with N = 2.
|