Download
wait die n.
Skip this Video
Loading SlideShow in 5 Seconds..
Wait-die PowerPoint Presentation

Wait-die

175 Vues Download Presentation
Télécharger la présentation

Wait-die

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Wait for C? Wait for A Wait fo B Wait-die • Transactions given a timestamp when they arrive …. ts(Ti) • Ti can only wait for Tj if ts(Ti)< ts(Tj) ...else die T1 (ts =10) T2 (ts =20) T3 (ts =25)

  2. Wait-die-1 requests A: wait for T2 or T3 or both? (in my html notes, I assume both) T1 (ts =22) T2 (ts =20) T3 (ts =25) Note: ts between 20 and 25. wait(A)

  3. wait(A) wait(A) Wait-die-1 One option: T1 waits just for T3, transaction holding lock. But when T2 gets lock, T1 will have to die! (also lots of WFG revision) T1 (ts =22) T2 (ts =20) T3 (ts =25) wait(A)

  4. Wait-die-2 Another option: T1 waits for both T2, T3 E.g., (saves having to revise WFG) T1 allowed to wait iff there is at least one younger trans wait-involved with A. But again, when T2 gets lock, T1 must die! T1 (ts =22) T2 (ts =20) T3 (ts =25) wait(A) wait(A) wait(A)

  5. wait(A) Wait-die-3 Yet another option: T1 preempts T2 (T2 is just waiting idly anyway), so T1 only waits for T3; T2 then waits for T3But,T2 may starve? And lots of WFG work for Deadlock Mgr (shifting edges) T1 (ts =22) T2 (ts =20) T3 (ts =25) wait-A

  6. Wound-wait • Transactions given a timestamp when they arrive … ts(Ti) • Ti wounds Tj if ts(Ti)< ts(Tj) else Ti waits “Wound”: Tj rolls back (if it cannot finish in small interval of time) and gives lock to Ti

  7. Wait C Wound-wait T1 (ts =25) T2 (ts =20) T3 (ts =10) Wait A Wait B

  8. Wound-wait-2 requests A: wait for T2 or T3? T1 (ts =15) T2 (ts =20) T3 (ts =10) Note: ts between 10 and 20. wait(A)

  9. Wound-wait-2 One option: T1 waits just for T3, transaction holding lock. But when T2 gets lock, T1 waits for T2 and wounds T2. T1 (ts =15) T2 (ts =20) T3 (ts =10) Wait A wait(A) wait(A)

  10. Wound-wait-3 Another option: T1 waits for both T2, T3 T2 wounded right away! T1 (ts =15) T2 (ts =20) T3 (ts =10) wait(A) wait(A) wait(A)

  11. Wound-wait-4 Yet another option: T1 preempts T2, so T1 only waits for T3; T2 then waits for T3 and T1...  T2 is spared! Lots of WFG work for Deadlock Mgr (shifting edges) and T2 may starve. T1 (ts =15) T2 (ts =20) T3 (ts =10) wait-A wait(A)