lec8_deadlock

lec8_deadlock - Announcement Principles of Operating...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE120 Principles of Operating Systems Prof Yuanyuan (YY) Zhou Lecture 9 Oct 21th, 2010 10/18/10 CSE 120 – Lecture 8 – Scheduling and Deadlock 2 Announcement Project 1: due on Oct 26 th Midterm: Oct 26 th in lecture April 23, 2009 CSE 120 – Lecture 8 – Scheduling and Deadlock 3 Deadlock Synchronization is a live gun – we can easily shoot ourselves in the foot Incorrect use of synchronization can block all processes You have likely been intuitively avoiding this situation already More generally, processes that allocate multiple resources, generate dependencies on those resources Locks, semaphores, monitors, etc., just represent the resources that they protect If one process tries to allocate a resource that a second process holds, and vice-versa, they can never make progress We call this situation deadlock , and we’ll look at: Definition and conditions necessary for deadlock Representation of deadlock conditions Approaches to dealing with deadlock Traffic Deadlock 10/18/10 CSE 120 – Lecture 4 – Threads 4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 5 Let’s Start with Resource A resource is a commodity needed by a process. Resources can be either: serially reusable : e.g., CPU, memory, disk space, I/O devices, files. acquire use release consumable : produced by a process, needed by a process; e.g., messages, buffers of information, interrupts. create acquire use (consumed) Resource ceases to exist after it has been used, so it is not released. 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 6 Resource (2) Resources can also be either: preemptible : e.g., CPU, or non-preemptible : e.g., tape drives. And resources can be either: shared among several processes or dedicated exclusively to a single process. April 23, 2009 CSE 120 – Lecture 8 – Scheduling and Deadlock 7 Deadlock Definition Deadlock is a problem that can arise: When processes compete for access to limited resources When processes are incorrectly synchronized Definition: A process is deadlocked if it is waiting for an event that will never occur. Typically, but not necessarily, more than one process will be involved together in a deadlock (the deadly embrace ). lockA->Acquire(); lockB->Acquire(); lockB->Acquire(); lockA->Acquire(); Process 1 Process 2 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 8 Using Semaphore to Share Resource Process P(); { A.Down(); B.Down(); use both resource B.Up(); A.Up(); } Process Q(); { A.Down(); B.Down(); use both resource B.Up(); A.Up(); } 4 2 3 External Semaphore A(1), B(1); External Semaphore A(0), B(1); 2 External Semaphore A(0), B(0); 3 External Semaphore A(0), B(1); 4 External Semaphore A(1), B(1); 5 5 0 6
Background image of page 2
3 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 9 But Deadlock can Happen! Process P();
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

lec8_deadlock - Announcement Principles of Operating...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online