Docsity

Deadlock Detection and Recovery in Computer Science (CMSC 412) - Prof. Jeffrey K. Hollings, Study notes of Operating Systems

Partial preview of the text

Download Deadlock Detection and Recovery in Computer Science (CMSC 412) - Prof. Jeffrey K. Hollings and more Study notes Operating Systems in PDF only on Docsity!

Announcements

z

Midterm is Thursday z

Project #2 is available on the web

Deadlock Detection

z

Resource Allocation Graph

  • Graph consists of vertices
    • type P = {P

,..,P 1

} represent processesn

  • type R = {R

,..,R 1

} represent resourcesm

  • Directed edge from process P

to resource type Ri^

signifiesj

that a process i has requested resource type j

-^

request edge

  • A directed edge from R

to Pj

indicates that resource Ri

hasj^

been allocated to process P

i

-^

assignment edge

Resource Allocation Graph

z

When a process P

requests an instance ofi^

resource type R

, a request edge is insertedj

into the resource allocation graph

z

When the request can be fulfilled, the requestedge is transformed into an assignment edge

z

When the process is done using theresource, the assignment edge is deleted

z

If the graph contains no cycles, no deadlockcan exist

Deadlock!

.^.

P

P

R1 R

No!!

P

P

P3 could finish withits instance of R1, releasethe instance, then P2would claim thatinstance of R

P

R1 R

P

R1 R

Then, P2 couldfinish with its instancesof R1 and R2 andrelease these resources.P1 then gets what it wants

P

P

Recovery from deadlock

z

Must free up resources by some means z

Process termination

  • kill all deadlocked processes– select one process and kill it
    • must re-run deadlock detection algorithm again to see if it

is freed.

z

Resource Preemption

  • select a process, resource and de-allocate it– rollback the process
    • needs to be reset the process to a safe state• this requires additional state
      • starvation
        • what prevents a process from never finishing?