Docsity

Deadlock Concepts - Operating Systems - Lecture Notes, Study notes of Operating Systems

Partial preview of the text

Download Deadlock Concepts - Operating Systems - Lecture Notes and more Study notes Operating Systems in PDF only on Docsity!

○ Other side of spectrum (from race conditions) ○ Nothing can continue. Circular dependencies: processes waiting for one another.

Resource saturation/starvation: not enough resources for anyone to continue.

○ Common forms Deadlock Deadlock Wednesday, October 13, 2004 3:08 PM Docsity.com

Race conditions are damaging during critical sections. Locks around critical sections prevent races/damage. Semantics are subtle. Last time Thursday, October 13, 2011 4:29 PM Docsity.com

Deadlock depends upon what happens when. It is often a chance occurrence. Deadlock schedule: a sequence of events in time that creates a deadlock. A situation is not a deadlock if there is any schedule of events under which computation can complete. Completion schedule: a sequence of events in time that demonstrates that a situation is not a deadlock. Deadlock concepts Tuesday, October 19, 2010 4:07 PM Docsity.com

What a process asks for is what it needs. If a process gets what it asks for, it completes. There are no outside influences. Basic assumptions processes ask for what they need, and they won't complete, without outside intervention (control-C). A deadlock occurs when Basic assumptions Thursday, October 13, 2011 4:32 PM Docsity.com

Boston Driver's Handbook. Thursday, October 13, 2011 4:36 PM Docsity.com

Two resources: A and B Two programs: P and Q Lock A Lock B Do something Release A Release B P's schedule: Lock B Lock A Do something Release B Release A Q's schedule: Circular dependency example Circular dependency example Wednesday, October 13, 2004 3:08 PM Docsity.com

If P, Q agree on order, deadlock is impossible. No agreement on order of locking. No communication between programmers. millions of lines of code to fix. Real cause of deadlock: legacy code Note: if P and Q agree on order Tuesday, October 19, 2010 4:45 PM Docsity.com

More than two processes Processes P1, P2, ... Resources R1, R2, … P1: P2: P3: P4: Lock R Lock R Lock R Lock R Lock R Lock R Lock R Lock R But what if every process asks for both locks at the same time? More than two processes Wednesday, October 13, 2004 3:08 PM Docsity.com

If every process asks for everything it needs all at once, deadlock cannot occur. It is the process of deciding what one wants that causes deadlock. Reason is that a process waits for some resources but already holds others. Example: reading a big file into memory as a linked list. Atomicity is the key Tuesday, October 19, 2010 2:09 PM Docsity.com

Special case of circular dependency Limited resources Demand exceeds supply Incremental allocation Resource starvation Resource starvation Wednesday, October 13, 2004 3:08 PM Docsity.com

Docsity.com

○ Only 6 memory elements available ○ Process 1 and 2 interleave requests: int *a[5]; for (i=0; i<5; i++) a[i]=getmem(); Example of resource deadlock: Example of resource locking Wednesday, October 13, 2004 3:08 PM Docsity.com

Circular dependency=deadlock Circular dependency Wednesday, October 13, 2004 6:03 PM Docsity.com

No deadlock No deadlock Wednesday, October 13, 2004 6:03 PM Docsity.com