1 / 16

Resource Management

Resource Management. Reusable Disk blocks File descriptors Semaphores Consumable Messages Packets. Resource State. Available Total 1 2+(1)+[1] 1 4 Owns 2, request 1, remaining-claim 1 2 1 Owns 1, cannot ask for any more [2] Owns none, maximum claim is 2.

charshaw
Download Presentation

Resource Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Resource State Available Total 1 2+(1)+[1] 1 4 Owns 2, request 1, remaining-claim 1 2 1 Owns 1, cannot ask for any more • [2] Owns none, maximum claim is 2

  3. Resource State Diagram Process 1 2 3 Resource avail total • 2+(1)+[1] 1 [2] 0 3 • 2 1+[1] 1+(1)+[1] 0 2 • 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 itspredecessor 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 • Collective requests • Release all before requesting more • Allow preemption • Havender’s Ordered Requests • request a resource in class C(i) only if it holds noresources 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 executionschedule of processes (P1, P2, ... , Pn) such that for each P(i), when it begins execution, its maximal claims can besatisfied by the available resources.

  11. A Safe State Process 1 2 3 Resource avail total • 1+[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 • 1+(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

More Related