lec8_deadlock - Announcement Principles of Operating...

Info icon This 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
Image of page 1

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

View Full Document Right 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
Image of page 2
3 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 9 But Deadlock can Happen! Process P(); { A.Down(); B.Down(); use both resources B.Up(); A.Up(); } Process Q(); { B.Down(); A.Down(); use both resources A.Up(); B.Up(); } 3 2 1 1 External Semaphore A(1), B(1); 1 External Semaphore A(0), B(1); 2 External Semaphore A(0), B(0); 3 10/18/10 CS 323 - Operating Systems, Yuanyuan Zhou 10 Deadlock Mechanism for Deadlock Control 10/18/10
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern