Topics: Deadlock, Resource allocation, Resource Pages: 7 (1111 words) Published: April 19, 2013
Operating Systems

User OS Kernel & Device Drivers Interface Programs


Brian Mitchell ( Operating Systems


• Computer resources are full of resources that can only be used by one process at a time • Unpredictable results can occur if two or more processes use the same resource at the same time • OS control this problem by arbitrating resource requests • OS grant exclusive access and manage access to system resources • By allowing processes to have exclusive access to resources problems may occur: – Starvation – Deadlock

Brian Mitchell ( Operating Systems


• Deadlock can occur if two or more processes are competing for two or more common resources • Deadlock causes all processes involved in the deadlock to become permanently blocked – Each process is waiting on resources owned by other processes that are also deadlocked

• Deadlock may be difficult to detect
– Often timing sensitive

• What to do about deadlocks:
– – – – Understand them Model them Develop ways to detect them Develop ways to avoid them Brian Mitchell ( Operating Systems 3

• Deadlocks occur when processes have been granted exclusive access to resources – Resources include semaphores, devices, files, …

• Resources come in two types:
– Preemptive resource: A resources that can be taken away from a process without any ill effects. • Example: memory

– Non-preemptive resource: A resource that can not be taken safely away from a process • Example: printer

• Deadlocks generally involve non-preemptive resources • Deadlocks can be easily fixed with preemptive resources – Take resources away from one or more deadlocked processes Brian Mitchell ( Operating Systems 4

Using Resources
• Access to resources should follow the model presented when we discussed critical sections – Request the resource – Use the resource – Release the resource

• If a resource is not available when requested, the requesting process should block • It is often difficult to develop a program that can continue if needed resources are not available • This model relies on well-behaved processes – What happens if a process does not release resources

• Timeout?
Brian Mitchell ( Operating Systems 5

Conditions for Deadlock
A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause • Conditions for deadlock: – Mutual exclusion condition. Each resources is either currently assigned to exactly one process or is available – Hold and wait condition. Processes currently holding resources granted earlier can request new resources – No preemption condition. Resources previously granted cannot be forcibly taken away from a process – Circular wait condition. There must be a circular chain of two or more processes where each is waiting for a resource held by the next member of the chain Brian Mitchell ( Operating Systems 6

Deadlock Modeling
• Deadlocks can be modeled by creating simple graphs.
– Circles are processes – Squares are resources – Edges represent a resource request or a resource being held by a process D C B D B Process A holds resource B Process C requests resource D Deadlock A



Brian Mitchell ( Operating Systems


Deadlock Modeling
• Draw all resources and processes • Add edges as resource requests and releases are requested • Check for a cycle in the graph to detect deadlock Process A: Request R, S; Release R, S Process B: Request S, T; Release S, T Process C: Request T, R; Release T, R










A requests R B requests S C requests T

A requests S B requests T
Brian Mitchell ( Operating Systems

C requests R DEADLOCK

How To Deal With Deadlocks
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Cpu Scheduling Essay
  • How VxWorks handles process scheduling and memory management in comparison to QNX Essay
  • scheduling system Essay
  • Scheduling Algorithm and Ready Queue Essay
  • Context Switch and Following Scheduling Algorithms Research Paper
  • Scheduling Essay
  • Essay on Task Scheduling Methods for Composable and Predictable MPSoCs
  • Essay about Flow Shop Scheduling Problem

Become a StudyMode Member

Sign Up - It's Free