Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.

Slides:



Advertisements
Similar presentations
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Advertisements

Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Operating Systems Lecture Notes Deadlocks Matthew Dailey Some material © Silberschatz, Galvin, and Gagne, 2002.
Concurrency: Deadlock and Starvation Chapter 6. Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Chapter 6: Process Synchronization
02/27/2004CSCI 315 Operating Systems Design1 Process Synchronization Deadlock Notice: The slides for this lecture have been largely based on those accompanying.
6.5 Semaphore Can only be accessed via two indivisible (atomic) operations wait (S) { while S
Chapter 6 Concurrency: Deadlock and Starvation
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.
CS 450 OPERATING SYSTEMS DEADLOCKS Manju Muralidharan Priya.
02/18/2008CSCI 315 Operating Systems Design1 Deadlock Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
OS Spring 2004 Concurrency: Principles of Deadlock Operating Systems Spring 2004.
Process Synchronization
CPSC 4650 Operating Systems Chapter 6 Deadlock and Starvation
OS Fall’02 Concurrency: Principles of Deadlock Operating Systems Fall 2002.
02/23/2004CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
1 Concurrency: Deadlock and Starvation Chapter 6.
02/17/2010CSCI 315 Operating Systems Design1 Process Synchronization Notice: The slides for this lecture have been largely based on those accompanying.
Chapter 6 Concurrency: Deadlock and Starvation
Silberschatz, Galvin and Gagne  Operating System Concepts Deadlock and Starvation Deadlock – two or more processes are waiting indefinitely for.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Process Synchronization.
Adopted from and based on Textbook: Operating System Concepts – 8th Edition, by Silberschatz, Galvin and Gagne Updated and Modified by Dr. Abdullah Basuhail,
Concurrency: Deadlock and Starvation Chapter 6. Goal and approach Deadlock and starvation Underlying principles Solutions? –Prevention –Detection –Avoidance.
1 Concurrency: Deadlock and Starvation Chapter 6.
Exam Review Operating Systems CS 550. Items of Interest Exam is Nov. 19, 2014 Focus on material since last exam, though knowledge of initial material.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof.
6.3 Peterson’s Solution The two processes share two variables: Int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical.
Operating Systems CMPSC 473 Mutual Exclusion Lecture 14: October 14, 2010 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic,
Operating Systems Part III: Process Management (Deadlocks)
1 Deadlock. 2 Concurrency Issues Past lectures:  Problem: Safely coordinate access to shared resource  Solutions:  Use semaphores, monitors, locks,
This Time - Deadlock Definition Conditions for deadlocks
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
CENG334 Introduction to Operating Systems Erol Sahin Dept of Computer Eng. Middle East Technical University Ankara, TURKEY URL:
Deadlock cs550 Operating Systems David Monismith.
Chapter 7 Deadlocks. 7.1 Introduction Deadlock Common approaches to deal with deadlock – Prevention – Avoidance – Detection and recovery.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
CS 241 Section Week #7 (10/22/09). Topics This Section  Midterm Statistics  MP5 Forward  Classical Synchronization Problems  Problems.
CS333 Intro to Operating Systems Jonathan Walpole.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings.
Deadlock Conditions for Deadlock Deadlock Prevention Deadlock Detection Deadlock Recovery Dining Philosophers Semaphores.
Deadlocks Mark Stanovich Operating Systems COP 4610.
Deadlocks.  Deadlocks: Occurs when threads are waiting for resources with circular dependencies Often involve nonpreemptable resources, which cannot.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 5: Process Synchronization.
Lecture 6 Deadlock 1. Deadlock and Starvation Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S);. signal (S);
6.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 6.5 Semaphore Less complicated than the hardware-based solutions Semaphore S – integer.
Chapter 6 Concurrency: Deadlock and Starvation Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community.
Concurrency: Deadlock and Starvation
Operating systems Deadlocks.
Auburn University COMP 3500 Introduction to Operating Systems Synchronization: Part 4 Classical Synchronization Problems.
Background on the need for Synchronization
Chapter 7: Deadlocks.
Process Synchronization
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.
Lecture 2 Part 2 Process Synchronization
Concurrency: Mutual Exclusion and Process Synchronization
Conditions for Deadlock
Andy Wang Operating Systems COP 4610 / CGS 5765
Deadlocks Session - 13.
CSE 153 Design of Operating Systems Winter 2019
CSE 542: Operating Systems
CSE 542: Operating Systems
Operating Systems {week 10}
Presentation transcript:

Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.

 Without synchronization amongst processes (and threads), results are unpredictable how do variables x and y become corrupted?

 Processes compete for resources  Once obtained, the resource is fully dedicated to a process  Often, mutual exclusion is required ▪ No other process is allowed access to the resource  Processes cooperate with other processes  Shared resources  Specific ordering or sequencing of events all of this applies to threads, too!

 A semaphore is a synchronization mechanism  Semaphore S is a special integer variable  OS provides two atomic operations on S:  wait(S) or P(S): ▪ wait for a resource to become available  signal(S) or V(S): ▪ signal that we’re done using a resource

 The wait(S) operation decrements semaphore S only when S is available  wait(S) { while ( S <= 0 ) { /** no-op **/ ; } S--; } this will block indefinitely in a busy wait

 The signal(S) operation increments semaphore S to release a resource  signal(S) { S++; } to protect critical section  wait(S); // CRITICAL // SECTION signal(S);

 A binary semaphore provides mutually exclusive access to a shared resource  Initialize semaphore S to 1  Use wait(S) and signal(S)  Possible values of S are 0 and 1

 A counting semaphore controls access to a finite number of resources:  e.g. open files, network connections, shared buffers, etc. // n instances of a finite resource semaphore S = n Write pseudocode for the producer-consumer problem using semaphores to synchronize access to the shared buffer of size N

 A process faces starvation when it is forced to wait indefinitely for shared resource X as other processes use that shared resource X  Also known as indefinite blocking

 A system enters a deadlock state when multiple processes are unable to obtain a lock on all necessary resources  After acquiring a resource, a process holds that resource indefinitely // P 0... wait(S) wait(Q)... signal(Q) signal(S)... // P 1... wait(Q) wait(S)... signal(S) signal(Q)... semaphore S, Q Deadlock!

 Deadlock requires four conditions:  Mutual exclusion  Hold and wait  No preemption  Circular wait ▪ i.e. a cycle!

 A resource allocation graph is a directed graph showing processes and resources

Rice  Five philosophers at a table  Each philosopher thinks or eats  To eat, a philosopher must pick up the closest two chopsticks  A philosopher may only pick up one chopstick at a time  Represents allocating shared resources to competing and cooperating processes

Rice  Potential solution:  Can deadlock occur? // philosopher i while ( true ) { think(); wait( fork[i] ); wait( fork[(i+1)%5] ); eat(); signal( fork[(i+1)%5] ); signal( fork[i] ); } semaphore fork[] = { 1, 1, 1, 1, 1 };

 Allow the system to enter a deadlock state, then recover by:  Terminating one or all deadlocked processes  Rollback deadlocked processes to a safe checkpointed state  Or....

 Guarantee that the system will never enter a deadlocked state  Deadlock prevention ensures that at least one of the four necessary conditions is never met  Deadlock avoidance allows a system to change state by allocating resource(s) only when it is certain deadlock will not occur as a result