Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
OS Chapter-2 Deadlocks

OS Chapter-2 Deadlocks

Ratings: (0)|Views: 3 |Likes:
Published by Anamika Raj
Operating Systems Chapters
Operating Systems Chapters

More info:

Published by: Anamika Raj on Apr 20, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/20/2013

pdf

text

original

 
Operating Systems-2 
peratng ystems- 
 
1
OPERATING SYSTEMS
 Prescribed Text Book 
 – 
 Operating System Principles, Seventh EditionByAbraham Silberschatz, Peter Baer Galvin and Greg Gagne
Page 1 / 14
Page 1 / 14
Page 1 / 14
 Mrs.Anamika Raj,Lecturer,King Khalid University
Chapter 2 Deadlocks
 
Operating Systems-2 
peratng ystems- 
 
2
DEADLOCKS
In a multi programming environment, several processes may compete for a finite number of resources. A process requests resources and if the resources are not available at that time, the process enters a waiting state. Sometimes, a waiting process is never again able to change state because the resources it has requested are held by other waiting processes. This situation is calleda dead lock.
System Model 
A system consists of a finite number of resources to be distributed among a number of competing processes. The resources are partitioned into several types, each consisting of some number of identical instances. Memory space, CPU cycles, files and I/O devices are examples of resourcetypes.If a process requests an instance of a resource type, the allocation of any instance of the type willsatisfy the request. If it will not, then the instances are not identical and the resource type classeshave not been defined properly.A process must request a resource before using it and must release the resource after using it. A process may request as many resources as it requires for carrying out its designated task.Under the normal mode of operation, a process may utilize a resource in the following sequence:1.
 
Request
 – 
requesting process must wait until it can acquire the resource2.
 
Use
 – 
process can operate on the resource3.
 
Release
 – 
process releases the resourceThe request and release of resources are system calls. Examples are the request () and release ()device, open () and close () file and allocate () and free () memory system calls. Request andrelease of resources that are not managed by the OS can be accomplished through the wait () andsignal () operations on semaphores or through acquisition () and release of mutex lock. A
systemtable
records whether each resource is free or allocated; for each resource that is allocated, thetable also records the process to which it is allocated. If a process requests a resource that iscurrently allocated to another process, it can be added to a queue of processes waiting for thisresource.A set of processes is in a deadlock state when every process in the set is waiting for an event thatcan be caused only by another process in the set. The events mainly concerned here are resourceacquisition and release. The resources may be either physical resources or logical resources.
Chapter 2 Deadlocks
 Mrs.Anamika Raj,Lecturer,King Khalid University
 
Operating Systems-2 
peratng ystems- 
 
3
A programmer developing multithreaded applications must pay particular attention to deadlocks.Multi threaded programs are good candidates for deadlock because multiple threads can competefor shared resources.
 Deadlock Characterization
In a deadlock, processes never finish executing and system resources are tied up, preventingother jobs from starting.
 Necessary Conditions
A deadlock situation can arise if following four conditions hold simultaneously in a system:*
 
Mutual exclusion: At least one resource must be held in a non sharable mode; that is onlyone process at a time can use the resource.*
 
Hold and wait: A process must be holding at least one resource and waiting to acquireadditional resources that are currently being held by other processes.*
 
 No preemption: Resources cannot be preempted; that is a resource can be released onlyvoluntarily by the process holding it, after that process has completed its task.*
 
Circular Wait: A set{ P
0
,P
1
,….P
n
} of waiting processes must exist such that P
0
is waitingfor a resource held by P
1,
…..P
n
is waiting for a resource held by P
0
.All the above four conditions must hold for a deadlock to occur.
 Resource Allocation Graph
Deadlocks can be described in terms of a directed graph called a
system resource allocationgraph
. This graph consists of a set of vertices V and set of edges E. The set of vertices V is partitioned into two different types of nodes:P
 – 
the set consisting of all the active processes in the system and
 – 
the set consisting of all resource types in the system.A directed edge from process P
i
to resource type R 
 j
is denoted by P
i
-> R 
 j
; it signifies that processP
i
has requested an instance of resource type R 
 j
and is currently waiting for that resource.
Chapter 2 Deadlocks
 Mrs.Anamika Raj,Lecturer,King Khalid University

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->