Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Process Synchronization and Deadlocks In a nutshell
Content Motivation Race Condition  Critical Section problem & Solutions Classical problems in Synchronization Deadlocks
Why study these chapters? This is about getting processes to coordinate with each other. How do processes work with resources that must be shared between them Very interesting concepts!
A race condition example A  race condition  is where multiple processes/threads concurrently read and write to a shared memory location and the result depends on the order of the execution. This was the cause of a patient death on a radiation therapy machine, the Therac-25 http://sunnyday.mit.edu/therac-25.html Yakima Software flow Also can happen in bank account database transactions with, say a husband and a wife accessing the same account simultaneously from different ATMs
A race condition example (2) We will implement count++ and count-- and run them concurrently Let us say they are executed by different threads accessing a global variable At the end we expect count's value not to change
A race condition example (3) count++  implementation: register1 = count register1 = register1 + 1 count = register 1 count--  implementation: register2 = count register2 = register2 - 1 count = register2 Let count = 5 initially. One possible concurrent execution of count++ and count-- is register1 = count  {register1 = 5} register1 = register1 + 1  {register1 = 6} register2 = count  {register2 = 5} register2 = register2 - 1  {register2 = 4} count = register1  {count = 6} count = register2  {count = 4} count = 4 after count++ and count--, even though we started with count = 5 Easy question: what other values can count be from doing this incorrectly?  Obviously, we would like to have count++ execute, followed by count-- (or vice versa)
A race condition example (4) Producer/consumer problem is more general form of the previous problem.
Critical Sections A  critical section  is a piece of code that accesses a shared resource (data structure or device) that must not be concurrently accessed by more than one thread of execution. The goal is to provide a mechanism by which only one instance of a critical section is executing for a particular shared resource. Unfortunately, it is often very difficult to detect critical section bugs
Critical Sections (2) A Critical Section Environment contains: Entry Section  Code requesting entry into the critical section. Critical Section  Code in which only one process can execute at any one time. Exit Section  The end of the critical section, releasing or allowing others in. Remainder Section  Rest of the code AFTER the critical section.
Critical Sections (3)
Solution to Critical-Section Problem The critical section must  ENFORCE ALL THREE  of the following rules: 1 .  Mutual Exclusion  - If process  P i  is executing in its critical section, then no other processes can be executing in their critical sections  In many calls, this is abbreviated mutex 2.  Progress  - If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely 3.  Bounded Waiting  - A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted Assume that each process executes at a nonzero speed No assumption concerning relative speed of the N processes
Critical Section Solutions Hardware Many systems provide hardware support for critical section code Uniprocessors – could disable interrupts Currently running code would execute without preemption Generally too inefficient on multiprocessor systems Have to wait for disable to propagate to all processors Operating systems using this not broadly scalable Modern machines provide special atomic hardware instructions Atomic = non-interruptable
Critical Section Solutions Software Peterson’s Solution : for two processes only. Semaphore : A flag used to indicate that a routine cannot proceed if a shared resource is already in use by another routine. The allowable operations on a semaphore are V("signal") and P("wait"); both are atomic operations.  Two types: counting and binary (mutex locks).
Some Classical Problems in Synchronization  Dining Philosophers.
Deadlocks
Bridge Crossing Example Traffic only in one direction. Each section of a bridge can be viewed as a resource. If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback). Several cars may have to be backed up if a deadlock occurs. Starvation is possible.
Deadlocks Deadlock: processes waiting indefinitely with no chance of making progress. Starvation: a process waits for a long time to make progress.
Deadlocks Deadlock applications not just OS Network Two processes may be blocking a send message to the other process if they are both waiting for a message from the other process Receive/waiting blocks writing Databases. Spooling/streaming data.
Deadlock Characterization Mutual exclusion:   only one process at a time can use a resource. Hold and wait:   a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption:   a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait:   there exists a set { P 0 ,  P 1 , …,  P 0 } of waiting processes such that  P 0  is waiting for a resource that is held by  P 1 ,  P 1  is waiting for a resource that is held by  P 2 , …,  P n –1  is waiting for a resource that is held by  P n , and  P 0  is waiting for a resource that is held by  P 0 . Deadlock can arise if four conditions hold simultaneously.
Resource-Allocation Graph V is partitioned into two types: P  = { P 1 ,  P 2 , …,  P n }, the set consisting of all the processes in the system. R  = { R 1 ,  R 2 , …,  R m }, the set consisting of all resource types in the system. request edge – directed edge  P 1     R j assignment edge – directed edge  R j      P i A set of vertices  V  and a set of edges  E .
Resource-Allocation Graph (Cont.) Process Resource Type with 4 instances P i   requests instance of  R j P i  is holding an instance of  R j P i P i R j R j
Example of a Resource Allocation Graph
Resource Allocation Graph With A Deadlock
Graph With A Cycle But No Deadlock
Basic Facts If graph contains no cycles    no deadlock. If graph contains a cycle   if only one instance per resource type, then deadlock. if several instances per resource type, possibility of deadlock.
Methods for Handling Deadlocks Ensure that the system will  never  enter a deadlock state. Allow the system to enter a deadlock state and then recover. Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.
Deadlock Prevention Mutual Exclusion  – not required for sharable resources; must hold for nonsharable resources. Hold and Wait  – must guarantee that whenever a process requests a resource, it does not hold any other resources. Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none. Low resource utilization; starvation possible. Restrain the ways request can be made.
Deadlock Prevention (Cont.) No Preemption  – If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released. Preempted resources are added to the list of resources for which the process is waiting. Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting. Circular Wait  – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
Deadlock Avoidance Simplest and most useful model requires that each process declare the  maximum number  of resources of each type that it may need. The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. Resource-allocation  state  is defined by the number of available and allocated resources, and the maximum demands of the processes. Requires that the system has some additional  a priori  information  available.
Useful Resources Amal Al-Hammad  http://os1h.pbwiki.com/deadlock Wajan Tamem http://os3a.pbwiki.com/%D8%A7%D9%84%D8%AC%D9%85%D9%88%D8%AF%20Deadlock

More Related Content

What's hot

Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
cscarcas
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
Dhaval Sakhiya
 
Concurrency
ConcurrencyConcurrency
Concurrency
rizwanaabassi
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
MOHIT DADU
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
Kathirvel Ayyaswamy
 
7 Deadlocks
7 Deadlocks7 Deadlocks
7 Deadlocks
Dr. Loganathan R
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
Shivam Mitra
 
Demand paging
Demand pagingDemand paging
Demand paging
Trinity Dwarka
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
Vaibhav Khanna
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
Harshana Madusanka Jayamaha
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
Wayne Jones Jnr
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
Venkata Sreeram
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
Kamal Acharya
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
sgpraju
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
Piyush Rochwani
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
Dr. C.V. Suresh Babu
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
Sonali Chauhan
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
salmancreation
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
Nishant Joshi
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
MsAnita2
 

What's hot (20)

Unit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process SynchronizationUnit II - 3 - Operating System - Process Synchronization
Unit II - 3 - Operating System - Process Synchronization
 
SCHEDULING ALGORITHMS
SCHEDULING ALGORITHMSSCHEDULING ALGORITHMS
SCHEDULING ALGORITHMS
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Critical section problem in operating system.
Critical section problem in operating system.Critical section problem in operating system.
Critical section problem in operating system.
 
Cs8493 unit 3
Cs8493 unit 3Cs8493 unit 3
Cs8493 unit 3
 
7 Deadlocks
7 Deadlocks7 Deadlocks
7 Deadlocks
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Operating system critical section
Operating system   critical sectionOperating system   critical section
Operating system critical section
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
DeadLock in Operating-Systems
DeadLock in Operating-SystemsDeadLock in Operating-Systems
DeadLock in Operating-Systems
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
OS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and MonitorsOS Process Synchronization, semaphore and Monitors
OS Process Synchronization, semaphore and Monitors
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Mutual exclusion and sync
Mutual exclusion and syncMutual exclusion and sync
Mutual exclusion and sync
 
Operating System-Threads-Galvin
Operating System-Threads-GalvinOperating System-Threads-Galvin
Operating System-Threads-Galvin
 
Deadlock Presentation
Deadlock PresentationDeadlock Presentation
Deadlock Presentation
 
Semophores and it's types
Semophores and it's typesSemophores and it's types
Semophores and it's types
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 

Viewers also liked

Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
Sonali Chauhan
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
Emery Berger
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
Nagarajan
 
Web technology
Web technologyWeb technology
Web technology
Selvin Josy Bai Somu
 
Web Tech
Web TechWeb Tech
Web Tech
Rupsee
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
Ritu Ranjan Shrivastwa
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
Ruaha Catholic university
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
Prasunjeet Soni
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
Shubhashish Punj
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
Abhishek Nagar
 

Viewers also liked (10)

Os Question Bank
Os Question BankOs Question Bank
Os Question Bank
 
Operating Systems - Synchronization
Operating Systems - SynchronizationOperating Systems - Synchronization
Operating Systems - Synchronization
 
Process synchronization(deepa)
Process synchronization(deepa)Process synchronization(deepa)
Process synchronization(deepa)
 
Web technology
Web technologyWeb technology
Web technology
 
Web Tech
Web TechWeb Tech
Web Tech
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
 
Process scheduling
Process schedulingProcess scheduling
Process scheduling
 
CPU Scheduling Algorithms
CPU Scheduling AlgorithmsCPU Scheduling Algorithms
CPU Scheduling Algorithms
 
Process Scheduling
Process SchedulingProcess Scheduling
Process Scheduling
 

Similar to Process Synchronization And Deadlocks

Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
Gichelle Amon
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
JeelBhanderi4
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
DHANABALSUBRAMANIAN
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Wakil Kumar
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
KAnurag2
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
wahab13
 
Deadlock
DeadlockDeadlock
Deadlock
Mahershi ACT
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Shipra Swati
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
MD.ANISUR RAHMAN
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
EktaVaswani2
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
ZainabShahzad9
 
os pdf ppt shanu.pptx presentation on slides
os pdf ppt shanu.pptx presentation on slidesos pdf ppt shanu.pptx presentation on slides
os pdf ppt shanu.pptx presentation on slides
siddhantpandey2410
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
Muhammad Baqar Kazmi
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
shreesha16
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systems
Rai University
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
SanthiNivas
 
Module3
Module3Module3
Module3
dilshad begum
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
Nivedita Kasturi
 
Deadlock
DeadlockDeadlock
Deadlock
Abhinaw Rai
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
sheraz7288
 

Similar to Process Synchronization And Deadlocks (20)

Os module 2 d
Os module 2 dOs module 2 d
Os module 2 d
 
Deadlock.ppt
Deadlock.pptDeadlock.ppt
Deadlock.ppt
 
OS UNIT3.pptx
OS UNIT3.pptxOS UNIT3.pptx
OS UNIT3.pptx
 
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...Deadlock- System model, resource types, deadlock problem, deadlock characteri...
Deadlock- System model, resource types, deadlock problem, deadlock characteri...
 
Module-2Deadlock.ppt
Module-2Deadlock.pptModule-2Deadlock.ppt
Module-2Deadlock.ppt
 
Mch7 deadlock
Mch7 deadlockMch7 deadlock
Mch7 deadlock
 
Deadlock
DeadlockDeadlock
Deadlock
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Deadlock and Banking Algorithm
Deadlock and Banking AlgorithmDeadlock and Banking Algorithm
Deadlock and Banking Algorithm
 
Deadlock and memory management -- Operating System
Deadlock and memory management -- Operating SystemDeadlock and memory management -- Operating System
Deadlock and memory management -- Operating System
 
OS 7.pptx
OS 7.pptxOS 7.pptx
OS 7.pptx
 
os pdf ppt shanu.pptx presentation on slides
os pdf ppt shanu.pptx presentation on slidesos pdf ppt shanu.pptx presentation on slides
os pdf ppt shanu.pptx presentation on slides
 
Critical section operating system
Critical section  operating systemCritical section  operating system
Critical section operating system
 
Module 3 Deadlocks.pptx
Module 3 Deadlocks.pptxModule 3 Deadlocks.pptx
Module 3 Deadlocks.pptx
 
Mca ii os u-3 dead lock & io systems
Mca  ii  os u-3 dead lock & io systemsMca  ii  os u-3 dead lock & io systems
Mca ii os u-3 dead lock & io systems
 
Deadlock in Operating System
Deadlock in Operating SystemDeadlock in Operating System
Deadlock in Operating System
 
Module3
Module3Module3
Module3
 
Gp1242 007 oer ppt
Gp1242 007 oer pptGp1242 007 oer ppt
Gp1242 007 oer ppt
 
Deadlock
DeadlockDeadlock
Deadlock
 
7308346-Deadlock.pptx
7308346-Deadlock.pptx7308346-Deadlock.pptx
7308346-Deadlock.pptx
 

More from tech2click

Ch13
Ch13Ch13
Ch12
Ch12Ch12
Ch11
Ch11Ch11
Ch10
Ch10Ch10
Ch8
Ch8Ch8
Tutorial4 Threads
Tutorial4  ThreadsTutorial4  Threads
Tutorial4 Threads
tech2click
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
tech2click
 
Mid1 Revision
Mid1  RevisionMid1  Revision
Mid1 Revision
tech2click
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
tech2click
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
tech2click
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
tech2click
 
Operating System 2
Operating System 2Operating System 2
Operating System 2
tech2click
 
Rootkit
RootkitRootkit
Rootkit
tech2click
 

More from tech2click (13)

Ch13
Ch13Ch13
Ch13
 
Ch12
Ch12Ch12
Ch12
 
Ch11
Ch11Ch11
Ch11
 
Ch10
Ch10Ch10
Ch10
 
Ch8
Ch8Ch8
Ch8
 
Tutorial4 Threads
Tutorial4  ThreadsTutorial4  Threads
Tutorial4 Threads
 
Operating System 5
Operating System 5Operating System 5
Operating System 5
 
Mid1 Revision
Mid1  RevisionMid1  Revision
Mid1 Revision
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
Operating System 3
Operating System 3Operating System 3
Operating System 3
 
Tutorial 2
Tutorial 2Tutorial 2
Tutorial 2
 
Operating System 2
Operating System 2Operating System 2
Operating System 2
 
Rootkit
RootkitRootkit
Rootkit
 

Recently uploaded

Kalyan Satta Matka Guessing Dp boss..143
Kalyan Satta Matka Guessing Dp boss..143Kalyan Satta Matka Guessing Dp boss..143
Kalyan Satta Matka Guessing Dp boss..143
Matka Guessing ❼ʘ❷ʘ❻❻➃➆➆➀ Matka Result
 
DPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRT
DPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRTDPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRT
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta MatkaIndian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Matka boss otg matka 420 matka otg matka boss
Matka boss otg matka 420 matka otg matka bossMatka boss otg matka 420 matka otg matka boss
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka GuessingMatka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Satta batta Matka Guessing Satta Matta Matka Indian Matka
Satta batta Matka Guessing Satta Matta Matka Indian MatkaSatta batta Matka Guessing Satta Matta Matka Indian Matka
Fix fix fix satta number Indian Matka Dpboss Matka guessing
Fix fix fix satta number Indian Matka Dpboss Matka guessingFix fix fix satta number Indian Matka Dpboss Matka guessing
Fix fix fix satta number Indian Matka Dpboss Matka guessing
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Satta matka matka satta satta Matta matka Indian Matka
Satta matka matka satta satta Matta matka Indian MatkaSatta matka matka satta satta Matta matka Indian Matka
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTGMATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Fix fix satta matka Dpboss Matka guessing kalyan matka
Fix fix satta matka Dpboss Matka guessing kalyan matkaFix fix satta matka Dpboss Matka guessing kalyan matka
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan MatkaSatta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Kalyan Today Kalyan Open Satta Matka 143
Kalyan Today Kalyan Open Satta Matka 143Kalyan Today Kalyan Open Satta Matka 143
Kalyan Today Kalyan Open Satta Matka 143
Matka Guessing ❼ʘ❷ʘ❻❻➃➆➆➀ Matka Result
 
Kalyan matka sattamatka Dpboss Dpboss Matka Dpboss satta
Kalyan matka sattamatka Dpboss Dpboss Matka Dpboss sattaKalyan matka sattamatka Dpboss Dpboss Matka Dpboss satta
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian MatkaSatta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Satta Matka Dpboss Guessing kalyan Indian chart result
Satta Matka Dpboss Guessing kalyan Indian chart resultSatta Matka Dpboss Guessing kalyan Indian chart result
Satta Matka Dpboss Guessing kalyan Indian chart result
❾❸❹❽❺❾❼❾❾⓿SATTA MATKA DPBOSS KALYAN MAIN BAZAR FAST MATKA ...
 
Matka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
Matka Boss otg Satta Matta Matka Kalyan Matka Indian MatkaMatka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
Matka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Indian Matka Dpboss Matka guessing satta
Indian Matka Dpboss Matka guessing sattaIndian Matka Dpboss Matka guessing satta
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
DP Boss Satta Matka Kalyan Matka
 

Recently uploaded (20)

Kalyan Satta Matka Guessing Dp boss..143
Kalyan Satta Matka Guessing Dp boss..143Kalyan Satta Matka Guessing Dp boss..143
Kalyan Satta Matka Guessing Dp boss..143
 
DPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRT
DPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRTDPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRT
DPBOSS GUESSING KALYAN SATTA MATKA KALYAN CHATRT
 
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta MatkaIndian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
Indian Matka Satta Matta Matka Dpboss Matka Boss otg Satta Matka
 
Matka boss otg matka 420 matka otg matka boss
Matka boss otg matka 420 matka otg matka bossMatka boss otg matka 420 matka otg matka boss
Matka boss otg matka 420 matka otg matka boss
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka GuessingMatka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
Matka boss otg Satta Matta Matka Indian Matka Dpboss Matka Guessing
 
Satta batta Matka Guessing Satta Matta Matka Indian Matka
Satta batta Matka Guessing Satta Matta Matka Indian MatkaSatta batta Matka Guessing Satta Matta Matka Indian Matka
Satta batta Matka Guessing Satta Matta Matka Indian Matka
 
Fix fix fix satta number Indian Matka Dpboss Matka guessing
Fix fix fix satta number Indian Matka Dpboss Matka guessingFix fix fix satta number Indian Matka Dpboss Matka guessing
Fix fix fix satta number Indian Matka Dpboss Matka guessing
 
Satta matka matka satta satta Matta matka Indian Matka
Satta matka matka satta satta Matta matka Indian MatkaSatta matka matka satta satta Matta matka Indian Matka
Satta matka matka satta satta Matta matka Indian Matka
 
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTGMATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
MATKA BOSS DPBOSS SATTA MATKA MATKA GUESSING MATKA BOSS OTG
 
Fix fix satta matka Dpboss Matka guessing kalyan matka
Fix fix satta matka Dpboss Matka guessing kalyan matkaFix fix satta matka Dpboss Matka guessing kalyan matka
Fix fix satta matka Dpboss Matka guessing kalyan matka
 
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan MatkaSatta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
Satta Matta Matka Kalyan Matka Satta Matka Dpboss Matka Guessing Kalyan Matka
 
Kalyan Today Kalyan Open Satta Matka 143
Kalyan Today Kalyan Open Satta Matka 143Kalyan Today Kalyan Open Satta Matka 143
Kalyan Today Kalyan Open Satta Matka 143
 
Kalyan matka sattamatka Dpboss Dpboss Matka Dpboss satta
Kalyan matka sattamatka Dpboss Dpboss Matka Dpboss sattaKalyan matka sattamatka Dpboss Dpboss Matka Dpboss satta
Kalyan matka sattamatka Dpboss Dpboss Matka Dpboss satta
 
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian MatkaSatta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
Satta Matta Matka Indian Matka Satta Matka Dpboss Matka boss otg Indian Matka
 
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
➒➌➎➏➑➐➋➑➐➐ Indian Matka Dpboss Matka boss otg
 
Satta Matka Dpboss Guessing kalyan Indian chart result
Satta Matka Dpboss Guessing kalyan Indian chart resultSatta Matka Dpboss Guessing kalyan Indian chart result
Satta Matka Dpboss Guessing kalyan Indian chart result
 
Matka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
Matka Boss otg Satta Matta Matka Kalyan Matka Indian MatkaMatka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
Matka Boss otg Satta Matta Matka Kalyan Matka Indian Matka
 
Indian Matka Dpboss Matka guessing satta
Indian Matka Dpboss Matka guessing sattaIndian Matka Dpboss Matka guessing satta
Indian Matka Dpboss Matka guessing satta
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart Call-⑨③④⑧⑧③⑥⑧⑧⑦
 

Process Synchronization And Deadlocks

  • 1. Process Synchronization and Deadlocks In a nutshell
  • 2. Content Motivation Race Condition Critical Section problem & Solutions Classical problems in Synchronization Deadlocks
  • 3. Why study these chapters? This is about getting processes to coordinate with each other. How do processes work with resources that must be shared between them Very interesting concepts!
  • 4. A race condition example A race condition is where multiple processes/threads concurrently read and write to a shared memory location and the result depends on the order of the execution. This was the cause of a patient death on a radiation therapy machine, the Therac-25 http://sunnyday.mit.edu/therac-25.html Yakima Software flow Also can happen in bank account database transactions with, say a husband and a wife accessing the same account simultaneously from different ATMs
  • 5. A race condition example (2) We will implement count++ and count-- and run them concurrently Let us say they are executed by different threads accessing a global variable At the end we expect count's value not to change
  • 6. A race condition example (3) count++ implementation: register1 = count register1 = register1 + 1 count = register 1 count-- implementation: register2 = count register2 = register2 - 1 count = register2 Let count = 5 initially. One possible concurrent execution of count++ and count-- is register1 = count {register1 = 5} register1 = register1 + 1 {register1 = 6} register2 = count {register2 = 5} register2 = register2 - 1 {register2 = 4} count = register1 {count = 6} count = register2 {count = 4} count = 4 after count++ and count--, even though we started with count = 5 Easy question: what other values can count be from doing this incorrectly? Obviously, we would like to have count++ execute, followed by count-- (or vice versa)
  • 7. A race condition example (4) Producer/consumer problem is more general form of the previous problem.
  • 8. Critical Sections A critical section is a piece of code that accesses a shared resource (data structure or device) that must not be concurrently accessed by more than one thread of execution. The goal is to provide a mechanism by which only one instance of a critical section is executing for a particular shared resource. Unfortunately, it is often very difficult to detect critical section bugs
  • 9. Critical Sections (2) A Critical Section Environment contains: Entry Section Code requesting entry into the critical section. Critical Section Code in which only one process can execute at any one time. Exit Section The end of the critical section, releasing or allowing others in. Remainder Section Rest of the code AFTER the critical section.
  • 11. Solution to Critical-Section Problem The critical section must ENFORCE ALL THREE of the following rules: 1 . Mutual Exclusion - If process P i is executing in its critical section, then no other processes can be executing in their critical sections In many calls, this is abbreviated mutex 2. Progress - If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then the selection of the processes that will enter the critical section next cannot be postponed indefinitely 3. Bounded Waiting - A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted Assume that each process executes at a nonzero speed No assumption concerning relative speed of the N processes
  • 12. Critical Section Solutions Hardware Many systems provide hardware support for critical section code Uniprocessors – could disable interrupts Currently running code would execute without preemption Generally too inefficient on multiprocessor systems Have to wait for disable to propagate to all processors Operating systems using this not broadly scalable Modern machines provide special atomic hardware instructions Atomic = non-interruptable
  • 13. Critical Section Solutions Software Peterson’s Solution : for two processes only. Semaphore : A flag used to indicate that a routine cannot proceed if a shared resource is already in use by another routine. The allowable operations on a semaphore are V("signal") and P("wait"); both are atomic operations. Two types: counting and binary (mutex locks).
  • 14. Some Classical Problems in Synchronization Dining Philosophers.
  • 16. Bridge Crossing Example Traffic only in one direction. Each section of a bridge can be viewed as a resource. If a deadlock occurs, it can be resolved if one car backs up (preempt resources and rollback). Several cars may have to be backed up if a deadlock occurs. Starvation is possible.
  • 17. Deadlocks Deadlock: processes waiting indefinitely with no chance of making progress. Starvation: a process waits for a long time to make progress.
  • 18. Deadlocks Deadlock applications not just OS Network Two processes may be blocking a send message to the other process if they are both waiting for a message from the other process Receive/waiting blocks writing Databases. Spooling/streaming data.
  • 19. Deadlock Characterization Mutual exclusion: only one process at a time can use a resource. Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes. No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task. Circular wait: there exists a set { P 0 , P 1 , …, P 0 } of waiting processes such that P 0 is waiting for a resource that is held by P 1 , P 1 is waiting for a resource that is held by P 2 , …, P n –1 is waiting for a resource that is held by P n , and P 0 is waiting for a resource that is held by P 0 . Deadlock can arise if four conditions hold simultaneously.
  • 20. Resource-Allocation Graph V is partitioned into two types: P = { P 1 , P 2 , …, P n }, the set consisting of all the processes in the system. R = { R 1 , R 2 , …, R m }, the set consisting of all resource types in the system. request edge – directed edge P 1  R j assignment edge – directed edge R j  P i A set of vertices V and a set of edges E .
  • 21. Resource-Allocation Graph (Cont.) Process Resource Type with 4 instances P i requests instance of R j P i is holding an instance of R j P i P i R j R j
  • 22. Example of a Resource Allocation Graph
  • 23. Resource Allocation Graph With A Deadlock
  • 24. Graph With A Cycle But No Deadlock
  • 25. Basic Facts If graph contains no cycles  no deadlock. If graph contains a cycle  if only one instance per resource type, then deadlock. if several instances per resource type, possibility of deadlock.
  • 26. Methods for Handling Deadlocks Ensure that the system will never enter a deadlock state. Allow the system to enter a deadlock state and then recover. Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.
  • 27. Deadlock Prevention Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources. Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources. Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none. Low resource utilization; starvation possible. Restrain the ways request can be made.
  • 28. Deadlock Prevention (Cont.) No Preemption – If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released. Preempted resources are added to the list of resources for which the process is waiting. Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting. Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.
  • 29. Deadlock Avoidance Simplest and most useful model requires that each process declare the maximum number of resources of each type that it may need. The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition. Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes. Requires that the system has some additional a priori information available.
  • 30. Useful Resources Amal Al-Hammad http://os1h.pbwiki.com/deadlock Wajan Tamem http://os3a.pbwiki.com/%D8%A7%D9%84%D8%AC%D9%85%D9%88%D8%AF%20Deadlock