Comp111: Operating Systems Classroom Exercise 9 The Bankers' Algorithm Fall 2017

group member 1: ____________________________ linux login: ______________ group member 2: ____________________________ linux login: ______________ group member 3: ____________________________ linux login: ______________ group member 4: ____________________________ linux login: ______________ group member 5: ____________________________ linux login: ______________ group member 6: ____________________________ linux login: ______________ group member 7: ____________________________ linux login: ______________ group member 8: ____________________________ linux login: ______________

In class we have studied the banker's algorithm for avoiding deadlock. Suppose we have three processes and four resources, in the following situation:
Requested Granted Deficit
R1R2R3R4 R1R2R3R4 R1R2R3R4
P14231 - P10000 = P14231
P22144 P20122 P22022
P35122 P35111 P30011
Totals
R1R2R3R4
5 2 4 4
In the above, "Totals" indicate total resources available.

1. Prove that this situation is safe by giving a schedule under which all processes can complete.

2. Under what conditions does a process in a Banker's Algorithm tableau remain runnable?
3. Suppose that we start with the above configuration and P1 asks for 3 more units of R4. Is that allocation safe? Why or why not?

4. Suppose that we start again from the above configuration and that P3 asks for 1 more unit of R3. Is that allocation safe? Why or why not?

5. Suppose that we start again from the above configuration and that P2 unexpectedly cancels all of its requests for R3 (e.g., in response to a signal), after which P3 asks for 1 more unit of R3. Is that allocation safe? Why or why not?

6. Why does the algorithm have to model situations in which resources are requested, available, and not granted?

7. (Advanced) Recall that malloc does not send a signal or kill the application when enough memory is not available, but rather, returns 0 to the application. In the context of this discussion, why is that behavior "preferable" to killing the process?