


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Lecture notes for cs 241 spring 2007 course on system programming, focusing on deadlock handling. Topics include deadlock modeling, strategies for dealing with deadlocks, prevention, and recovery. Students are expected to read stallings chapter 6 and prepare for quiz 7 on queuing and deadlock handling. Assignments lmp1, lmp2, and lmp3 are part of the course, with lmp1 starting and split into two parts.
Typology: Study notes
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















CS 241 Spring 2007System Programming
B^ C
Resource Allocation Graph (multiple resource types)
While did not get all resources {^ P(mutex)^ Try to pick up all resources^ if did not get all resources put resources back^ V(mutex)^ wait a while and try again } Use resources P(mutex) Release all resources V(mutex
while need a resource^ {^ P(mutex)^ Test to see if resource is free^ if free, grab resource else release all resources^ V(mutex)^ Wait a while and try again^ }
safe^ state
Available (Banker) Processes^ |^ A B^ | A B | A B |
A B --------------------------------------------------------------------------------------------------------------------- P1^3 0 5
2 3 6 5 P2^2 2 6
4 3 P3^1 3 9
8 5 P4^0 5 8
8 0 Sequence: ^ P1 can go^ (borrows from Banker A(2) and B(3), since Need.A(2) is less than Available A(6) andNeed.B(3) < Available.B(5). After lending, Available will be A(4), B(2)). After P1 finishes it releasesAllocated Resources A(3) and B(0) to the banker, and so the banker will have A(8) = A(6) + A(3) andB(5)=B(5)+B(0) available ^ P2 can go ( borrows from Banker A(4) and B(3)). After P2 finishes it releases the allocated resourceA(1) and B(3) to the banker and available will be A(11), B(7) ^ P3 can go^ (borrows from Banker A(8) and B(5), since Need.A(8) < Available.A(11) and Need.B(5) <Available.B(7)). After P3 finishes, it releases the allocated resources to the banker and Availableresources will be A(12) = A(11) + A(1) and B(10)=B(7+B(3) ^ P4 can go^ because P4 can borrow from Banker Need.A(8) < Available.A(12) andNeed.B(0)<Available.B(10). After P4 finishes, the resources are released, and Banker will haveavailable A(12) and B(15) ^ Hence, there exists a safe sequence with this snapshot of resources and processes. The safesequence is P1, P2, P3, P
-^ let’s assume Max/Need
Max^ Need^ Available (Banker) Processes^ |^ A B^ |^
Sequence: ^ P1 can’t go^ because Need.B(6) > Available.B(5) ^ P2 can’t go^ because Need.A(7) > Available.A(6) ^ P3 can’t go^ because Need.A(8) > Available.A(6) ^ P4 can’t go^ because Need.A(8) > Available.A(6) ^ Hence, there is no safe sequence and this is snapshot is in “unsafe” state