Resource Allocation and Deadlock Prevention, Lecture notes of Operating Systems

The process of resource allocation in operating systems and the potential issue of deadlock. It explains how semaphores can be used to synchronize resource allocation and the multiple resource allocation problem that can lead to deadlock. An example of deadlock and defines the general concept of deadlock. It also outlines the disadvantages of deadlock and the conditions that lead to deadlock. The document then introduces methods for dealing with deadlock, including prevention, avoidance, and detection and recovery.

Typology: Lecture notes

2017/2018

Uploaded on 08/28/2018

ivawen
ivawen 🇺🇸

1 document

1 / 61

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
OPERATING SYSTEMS
CS3502
Spring 2018
Deadlocks
Chapter 7
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d

Partial preview of the text

Download Resource Allocation and Deadlock Prevention and more Lecture notes Operating Systems in PDF only on Docsity!

OPERATING SYSTEMS

CS

Spring 2018

Deadlocks

Chapter 7

Resource Allocation and Deallocation When a process needs resources, it will normally follow the sequence:

  1. Request a number of instances of one or more resource types. If the resource units requested are not available, then process must wait
  2. Acquire the resource(s), the OS allocates resources
  3. Use the resource(s) for a finite period.
  4. Release the resource(s).

Multiple Resource Allocation Problem  Several processes may compete for multiple resources  If the allocation of multiple resources to processes is not done with proper synchronization, deadlock might occur  This waiting state is much more involved than starvation

Deadlock Problem A state of the computer system is which:  A set of blocked (suspended) processes  Each process holding one or more resources  Processes waiting to acquire one or more resources held by other processes

Deadlock – General Definition  A set of processes is in a deadlock state when every processes in the set is waiting for an event that can only be caused by another process in the set.  The events of interest are:  allocations of resources  release of resources  The resources are: CPU cycles, memory spaces, files, I/O devices in the computer system.

Disadvantage Of Deadlock  Deadlocked processes can never complete execution because they are waiting indefinitely  System resources are tied up because they are held by deadlocked processes.  Deadlocks are undesirable because they normally slow down a system

Deadlock Result Both processes are blocked, they cannot proceed.

Conditions For Deadlock A deadlock arises if four conditions hold simultaneously in a system:  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.

About These Conditions These conditions are necessary but not sufficient for deadlock to occur.

Resource Allocation Graph

A resource allocation graph shows the relationships between processes and resources. It consists of the following components:  A set of processes P = { P0, P1, …., Pi,…., Pn }  A set of resource types, R = { R0, R1, …,Rj, ..,Rm }  A set of directed edges

A Resource Allocation Graph

Resource Allocation Graph with Cycle

Analysis Resource Allocation Graph  If the graph contains no cycles, no deadlock exists.  If the graph contain cycles  if each resource type has only 1 instance, then a deadlock exists.  otherwise, a deadlock may exist.

Handling Deadlocks General approaches, the OS can:  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.