Section 3. True/False Changing the order of semaphores’ operations in a program does not matter. False.

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

Deadlocks pp System Model 1.Request 2.Use 3.Release Necessary Conditions 1.Mutual exclusion (non-sharable) 2.Hold and wait (holding at least one.
1 Concurrency: Deadlock and Starvation Chapter 6.
Lecture 8 Restrictions on Resource Allocation Dining Philosophers - Havender's Linear Ordering.
Deadlock Prevention, Avoidance, and Detection
ICS Principles of Operating Systems Lectures 8 and 9 - Deadlocks Prof. Dmitri V. Kalashnikov dvk ics.uci.edu Slides © Prof. Nalini Venkatasubramanian.
Deadlock and Starvation
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Deadlock Prevention, Avoidance, and Detection.  The Deadlock problem The Deadlock problem  Conditions for deadlocks Conditions for deadlocks  Graph-theoretic.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
CS 162 Discussion Section Week 4 9/ /4. Today’s Section ●Project administrivia ●Quiz ●Lecture Review ●Worksheet and Discussion.
Deadlocks Andy Wang Operating Systems COP 4610 / CGS 5765.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
Deadlock Chapter 3 R1 R2 P2P1 Allocated Requested.
Multi-Object Synchronization. Main Points Problems with synchronizing multiple objects Definition of deadlock – Circular waiting for resources Conditions.
1 Wednesday, June 28, 2006 Command, n.: Statement presented by a human and accepted by a computer in such a manner as to make the human feel that he is.
Deadlock CSCI 444/544 Operating Systems Fall 2008.
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
Chapter 3 Deadlocks 3.1. Resource 3.2. Introduction to deadlocks
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
Deadlock Detection with One Resource of Each Type (1)
Chapter 6 Deadlocks Resources Introduction Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
Deadlocks Gordon College Stephen Brinton. Deadlock Overview The Deadlock Problem System Model Deadlock Characterization Methods for Handling Deadlocks.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 7: Deadlock Dr. Mohamed Hefeeda.
CS510 Concurrent Systems Introduction to Concurrency.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 7: Deadlocks Modified.
1 Deadlocks Chapter Resource 3.2. Introduction to deadlocks 3.4. Deadlock detection and recovery 3.5. Deadlock avoidance 3.6. Deadlock prevention.
2001 Networking Operating Systems (CO32010) 1. Operating Systems 2. Processes and scheduling 4.
1 MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 6 Deadlocks Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All.
This Time - Deadlock Definition Conditions for deadlocks
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
CS333 Intro to Operating Systems Jonathan Walpole.
Deadlocks Mark Stanovich Operating Systems COP 4610.
Resource Management: Chap 9 Reusable  Disk blocks  File descriptors  Semaphores Consumable  Messages  Packets.
Deadlocks.  Deadlocks: Occurs when threads are waiting for resources with circular dependencies Often involve nonpreemptable resources, which cannot.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 6 Deadlocks Slide 1 Chapter 6 Deadlocks.
CS510 Concurrent Systems Jonathan Walpole. Introduction to Concurrency.
Tutorial 3: Homework 2 and Project 2
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
CS162 Section 2. True/False A thread needs to own a semaphore, meaning the thread has called semaphore.P(), before it can call semaphore.V() False: Any.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Deadlock.
NETW 3005 Monitors and Deadlocks. Reading For this lecture, you should have read Chapter 7. NETW3005 (Operating Systems) Lecture 06 - Deadlocks2.
Process Management Deadlocks.
Auburn University COMP 3500 Introduction to Operating Systems Resource Allocation Graphs Handling Deadlocks Dr. Xiao.
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Operating systems Deadlocks.
ITEC 202 Operating Systems
Chapter 7: Deadlocks Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Operating System: DEADLOCKS
Introduction to Operating Systems
ICS 143 Principles of Operating Systems
CS 143A – Winter 2013 Quiz 2 Solutions.
Midterm review: closed book multiple choice chapters 1 to 9
Deadlocks Definition A set of processes is in a Deadlock state when every process in the set is waiting for an event that can only be caused by another.
Operating systems Deadlocks.
CS 333 Introduction to Operating Systems Class 7 - Deadlock
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Andy Wang Operating Systems COP 4610 / CGS 5765
DEADLOCK.
SE350: Operating Systems Lecture 5: Deadlock.
Monitors and Inter-Process Communication
EECE.4810/EECE.5730 Operating Systems
CSE 542: Operating Systems
CSE 542: Operating Systems
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Deadlock CSE 2431: Introduction to Operating Systems
Presentation transcript:

Section 3

True/False Changing the order of semaphores’ operations in a program does not matter. False

True/False Apple was the first company to develop mice and overlapping windows. False: Xerox Parc was the first to develop Mice and Windows

True/False If the banker's algorithm finds that it's safe to allocate a resource to an existing thread, then all threads will eventually complete. False: The banker’s algorithm simply prevents resource-related deadlock. One of the threads could still go into an infinite loop and fail to complete.

Short Answers List the four requirements for deadlock Mutual exclusion Non-preemptable Resources hold and wait Circular chain of waiting.

Deadlock Consider a system with four processes P1, P2, P3, and P4, and two resources, R1, and R2, respectively. Each resource has two instances. Furthermore: - P1 allocates an instance of R2, and requests an instance of R1; - P2 allocates an instance of R1, and doesn’t need any other resource; - P3 allocates an instance of R1 and requires an instance of R2; - P4 allocates an instance of R2, and doesn’t need any other resource

a). Draw the resource allocation graph.

b). Is there a cycle in the graph? If yes name it. P2 and P4 are running, P1 is waiting for R1, and P2 is waiting for R2.

c). Is the system in deadlock? If yes, explain why. If not, give a possible sequence of executions after which every process completes. There is a cycle, but no deadlock. - P2 finishes, release R1; - P4 finishes, release R2; - P1 acquires R1, finishes and release R1,R2; - P3 acquires R2, finishes and release R1,R2;

Producer and Consumer

Consider the following two functions implementing a producer and consumer by using monitors: void send(item) { lock.acquire() enqueue(item); printf(“before signal()\n”); dataready.signal(&lock); printf(“after signal()\n”); lock.release(); } item = get() { lock.acquire(); while (queue.isEmpty()) { printf(“before wait()\n”); dataready.wait(&lock); printf(“after wait()\n”); } item = dequeue(); lock.release(); }

a). Use no more than three sentences to contrast Hoare and Mesa monitors With Hoare the signaler gives the CPU and the lock to the waiter; With Mesa the signaler schedules the waiter, and then finishes.

b). Assume two threads T1 and T2, as follows: T1 T2 send(item); item = get(); What are the possible outputs if the monitor uses the Hoare implementation? [T2, T1] before wait before signal after wait after signal [T1, T2] before signal after_signal

C). Repeat question (b) for a Mesa implementation of the monitor [T1, T2] before signal after_signal [T2, T1] before wait before signal after signal after wait

d). Now assume a third thread T3, i.e., T1 T2 T3 send(item); item = get(); send(item); What are the possible outputs if the monitor uses the Hoare implementation? Please specify from which thread does an output come by specifying the thread id in front of the output line, e.g., [T1] before signal or [T2] after wait.

[T1, T2/T3] [T3, T1/T2] [T1] before signal [T3] before signal [T1] after signal [T3] after signal [T3] before signal [T1] before signal [T3] after signal [T1] after signal

[T2, T1, T3] [T2, T3, T1] [T2] before wait [T1] before signal [T3] before signal [T2] after wait [T1] after signal [T3] after signal [T3] before signal [T1] before signal [T3] after signal [T1] after signal