Presentation is loading. Please wait.

Presentation is loading. Please wait.

Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets.

Similar presentations


Presentation on theme: "Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets."— Presentation transcript:

1 Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets

2 Resource State AvailableTotal 12+(1)+[1]1 4 Owns 2, request 1, remaining-claim 1 21 Owns 1, cannot ask for any more 3[2] Owns none, maximum claim is 2

3 Resource State Diagram Process 1 2 3 Resource avail total 12+(1)+[1] 1 [2] 0 3 2 2 1+[1] 1+(1)+[1] 0 2 3 3 1+(1)[1] 1 0 2 3 RESOURCES 3 PROCESSES Process 1 owns 2 units of R1, has requested 1 more with a remaining claim of 1 unit. There are no R1 units avail.

4 Deadlock Guarantees No Effective Deadlock A request must be granted in finite time even if new requests are accepted. No Deadlock A request must be granted in finite time assuming that no further requests are accepted.

5 Effective Deadlock Example Process 1 2 3 Resource avail total 1 1+[1] (2)+[2] 1+[1] 0 2 Process 1 and 3 alternate requests for 1 unit at a time. Process 2’s request for 2 units is never satisfied.

6 Necessary Conditions for Deadlock (1) Processes claim exclusive control. (2) Processes hold resources while requesting additional resources. (3) Resources cannot be forcibly removed (preempted) from processes. (4) A circular chain of processes exist such that each process holds one or more of the resources requested by its predecessor in the chain. If not, one of the processes would eventually receive a resource that it needed to complete.

7 Solution Classes Prevention  Static, works before programs execute Avoidance  Dynamic, check every request for safety  Delay request if not safe Detection/Recovery  Check for “stuck” processes at intervals

8 Prevention No exclusive control -- share everything No incremental requests 1.Collective requests 2.Release all before requesting more Allow preemption Havender’s Ordered Requests request a resource in class C(i) only if it holds no resources in any class C(j), j>=i. Dijkstra’s Minimal Progress

9 Havender Ordered Request Example (works for locks too!) Class Resource Type 6 Printer 5 Disk 1 4 Tape Drives 1 and 2 3 Disk 2 2 Tape Drives 3 and 4 1 Memory

10 Avoidance - tasks required to provide maximum claim resource counts prior to execution A request is granted only if it results in a SAFE resource state. Requires Max Claim information. A safe execution sequence (SES) is an execution schedule of processes (P1, P2,..., Pn) such that for each P(i), when it begins execution, its maximal claims can be satisfied by the available resources.

11 A Safe State Process 1 2 3 Resource avail total 11+[4] 3+(1)+[4] 3+[3] 3 10 Safe Execution Sequences = (P3, P1, P2) (P3, P2, P1)

12 An Unsafe State Process 1 2 3 Resource avail total 11+(1)+[4] 4+[3] 3+[3] 2 10 NO Safe Execution Sequence exists!

13 Banker’s Algorithm On every request, search for a SES such that  Every process can have its MAXIMUM CLAIM satisfied in at least one execution order Most Liberal because it gives away all resources if possible at the cost of execution order flexibility

14 Detection and Recovery For single-unit resources (semaphores/files), a cycle is a necessary and sufficient condition for deadlock.

15 Detection and Recovery Process 1 2 3 4 Resource available total 1 1+(1) 1 (1) 1 0 3 2 1+(1) 1 0 0 2 A cycle (P1 P2) exists but no deadlock because P4 can terminate and give a resource back. Note: not single unit resources.

16 Recovery Options Terminate operating system Terminate all processes in a cycle Terminate one process in a cycle Preempt resources


Download ppt "Resource Management Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets."

Similar presentations


Ads by Google