DOC PREVIEW
UB CSE 421 - Deadlock B.Ramamurthy

This preview shows page 1-2-14-15-29-30 out of 30 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 30 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

DeadlockIntroductionSystem ModelDeadlock CharacterizationResource-Allocation GraphResource-Allocation Graph (Cont.)Example of a Resource Allocation GraphResource Allocation Graph With A DeadlockResource Allocation Graph With A Cycle But No DeadlockBasic FactsMethods for Handling DeadlocksDeadlock PreventionDeadlock Prevention (Cont.)Deadlock AvoidanceSafe StateBasic FactsSafe, Unsafe , Deadlock StateResource-Allocation Graph AlgorithmResource-Allocation Graph For Deadlock AvoidanceUnsafe State In Resource-Allocation GraphBanker’s AlgorithmData Structures for the Banker’s AlgorithmSafety AlgorithmResource-Request Algorithm for Process PiExample of Banker’s AlgorithmExample (Cont.)Example P1 Request (1,0,2) (Cont.)Deadlock DetectionSingle Instance of Each Resource TypeResource-Allocation Graph and Wait-for Graph10/3/02 B.Ramamurthy 1Deadlock B.RamamurthyCSE42110/3/02 B.Ramamurthy 2IntroductionParallel operation among many devices driven by concurrent processes contribute significantly to high performance. But concurrency also results in contention for resources and possibility of deadlock among the vying processes.Deadlockis a situation where a group of processes are permanently blocked waiting for the resources held by each other in the group.Typical application where deadlock is a serious problem: Operating system, data base accesses, and distributed processing.10/3/02 B.Ramamurthy 3System ModelResource types R1, R2, . . ., RmCPU cycles, memory space, I/O devicesEach resource type Rihas Wiinstances.Each process utilizes a resource as follows:n request n use n release10/3/02 B.Ramamurthy 4Deadlock CharacterizationDeadlock can arise if four conditions hold simultaneously.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 {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1is waiting for a resource that is held by P2, …, Pn–1is waiting for a resource that is held by Pn, and P0is waiting for a resource that is held by P0.10/3/02 B.Ramamurthy 5Resource-Allocation GraphA set of vertices V and a set of edges E.V is partitioned into two types:nP= {P1, P2, …, Pn}, the set consisting of all the processes in the system.nR= {R1, R2, …, Rm}, the set consisting of all resource types in the system.request edge – directed edge P1 ®Rjassignment edge – directed edge Rj®Pi10/3/02 B.Ramamurthy 6Resource-Allocation Graph (Cont.)ProcessResource Type with 4 instancesPirequests instance of RjPiis holding an instance of RjRjPiPiRj10/3/02 B.Ramamurthy 7Example of a Resource Allocation Graph10/3/02 B.Ramamurthy 8Resource Allocation Graph With A Deadlock10/3/02 B.Ramamurthy 9Resource Allocation Graph With A Cycle But No Deadlock10/3/02 B.Ramamurthy 10Basic FactsIf graph contains no cycles Þ no deadlock.If graph contains a cycle Þn if only one instance per resource type, then deadlock.n if several instances per resource type, possibility of deadlock.10/3/02 B.Ramamurthy 11Methods for Handling DeadlocksEnsure that the system will neverenter 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.10/3/02 B.Ramamurthy 12Deadlock PreventionRestrain the ways request can be made.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.n 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.n Low resource utilization; starvation possible.10/3/02 B.Ramamurthy 13Deadlock Prevention (Cont.)No Preemption –n 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.n Preempted resources are added to the list of resources for which the process is waiting.n 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.10/3/02 B.Ramamurthy 14Deadlock AvoidanceSimplest and most useful model requires that each process declare the maximum numberof 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 stateis 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.10/3/02 B.Ramamurthy 15Safe StateWhen a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state.System is in safe state if there exists a safe sequence of all processes. Sequence <P1, P2, …, Pn> is safe if for eachPi, the resources that Pican still request can be satisfied by currently available resources + resources held by all the Pj, with j<I.n If Piresource needs are not immediately available, then Pican wait until all Pjhave finished.n When Pjis finished, Pican obtain needed resources, execute, return allocated resources, and terminate. n When Piterminates, Pi+1can obtain its needed resources, and so on.10/3/02 B.Ramamurthy 16Basic FactsIf a system is in safe state Þ no deadlocks.If a system is in unsafe state Þpossibility of deadlock.Avoidance Þ ensure that a system will never enter an unsafe state.10/3/02 B.Ramamurthy 17Safe, Unsafe , Deadlock State10/3/02 B.Ramamurthy 18Resource-Allocation Graph AlgorithmClaim edge Pi®Rjindicated that process Pjmay request resource Rj; represented by a dashed line.Claim edge converts to request edge when a process requests a resource.When a resource is released by a process, assignment edge reconverts to a claim edge.Resources must be claimed a prioriin the system.10/3/02 B.Ramamurthy 19Resource-Allocation Graph For Deadlock


View Full Document

UB CSE 421 - Deadlock B.Ramamurthy

Documents in this Course
Security

Security

28 pages

Threads

Threads

24 pages

Security

Security

20 pages

Security

Security

52 pages

Security

Security

20 pages

Load more
Download Deadlock B.Ramamurthy
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Deadlock B.Ramamurthy and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Deadlock B.Ramamurthy 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?