1 / 12

Detecting Deadlock Multiple resources of each type Adapted From Satya, 15-412 Fall ‘99

Detecting Deadlock Multiple resources of each type Adapted From Satya, 15-412 Fall ‘99. E =. e 0 e 1 e 2 … e n-1. Entirety. Initial State. n resources. E =. e 0 e 1 e 2 … e n-1. Entirety. A =. a 0 a 1 a 2 … a n-1. Available. c 0 0 c 0 1 c 0 2 … c 0 n-1

tevy
Download Presentation

Detecting Deadlock Multiple resources of each type Adapted From Satya, 15-412 Fall ‘99

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Detecting DeadlockMultiple resources of each typeAdapted From Satya, 15-412 Fall ‘99

  2. E = e0 e1 e2 … en-1 Entirety Initial State n resources

  3. E = e0 e1 e2 … en-1 Entirety A = a0 a1 a2 … an-1 Available c00 c01 c02 … c0n-1 c10 c11 … c1n-1 … cij… cm-10cm-11 cm-12 … cm-1n-1 C = Current At Any Point n resources m processes

  4. n resources r00 r01 r02 … r0n-1 r10 r11 … r1n-1 … rij… rm-10rm-11 rm-12 … rm-1n-1 R = Request New Request m processes

  5. Testing for Deadlock • while ( unmarked rows exist inR ) { • find unmarked rowkinRsuch thatRkA • if ( no such row found ) • { report deadlock and quit} • else { • mark rowk; /* this process’ request can be granted */ • A+= Ck; /* held resources will be returned finally */ • } • } • if we reach here, there is no deadlock

  6. n resources A = a0 a1 a2 … an-1 Available r00 r01 r02 … r0n-1 r10 r11 … r1n-1 … rij… rm-10rm-11 rm-12 … rm-1n-1 R = Request Example: R1A m processes

  7. Dynamic Deadlock Avoidance Banker’s algorithm Adapted From Satya, 15-412 Fall ‘99

  8. E = e0 e1 e2 … en-1 Entirety l00 l01 l02 … l0n-1 l10 l11 … l1n-1 … cij… lm-10lm-11 lm-12 … lm-1n-1 L = Line of credit Initial State n resources m processes

  9. E = e0 e1 e2 … en-1 Entirety A = a0 a1 a2 … an-1 Available c00 c01 c02 … c0n-1 c10 c11 … c1n-1 … cij… cm-10cm-11 cm-12 … cm-1n-1 C = Current At Any Point n resources m processes

  10. Residual Credit R = L - C r00 r01 r02 … r0n-1 r10 r11 … r1n-1 … rij… rm-10rm-11 rm-12 … rm-1n-1 R = Residual Credit

  11. n resources N = n0 n1 n2 … nn-1 New Request by Process i

  12. Is it Safe to Allocate N? • Pretend request is granted • Update state variables • Ci = Ci + N • Ri= Ri- N • A = A - N • Run deadlock detection with C, R, A • no deadlock  allocation safe • deadlock  allocation unsafe; • undo changes to C, R, A • block process I until A increases, then retry

More Related