self verifying verifying self self verifying dining
play

Self- -Verifying Verifying Self Self-Verifying * * Dining - PowerPoint PPT Presentation

Self- -Verifying Verifying Self Self-Verifying * * Dining Philosophers Dining Philosophers Dining Philosophers Peter Welch and Neil Brown Peter Welch and Neil Brown School of Computing, University of Kent, UK School of Computing,


  1. Self- -Verifying Verifying Self Self-Verifying * * Dining Philosophers Dining Philosophers Dining Philosophers Peter Welch and Neil Brown Peter Welch and Neil Brown School of Computing, University of Kent, UK School of Computing, University of Kent, UK IFIP WG2.4, Cape May, 30 th . September, 2011 2000 2000 * About 10 of them … * About 10 of them … 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 1

  2. � � � � The Dining Philosophers The Dining Philosophers � � � � � � The Dining Philosophers is due to The story of The Dining Philosophers is due to Edsger Edsger The story of Dijkstra – – one of the founding fathers of Computer Science. one of the founding fathers of Computer Science. Dijkstra It illustrates a classic problem in concurrency: how to share It illustrates a classic problem in concurrency: how to share resources safely between competing consumers. . resources safely between competing consumers http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD310.PDF http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD310.PDF http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD310.PDF Historical document Historical document 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 2

  3. thinking thinking eatBar eatBar eating eating College College P P F F F F P P P P F F F F F F P P P P A new, really really really neat, solution (Neil Brown / PHW) neat, solution (Neil Brown / PHW) A new, really 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 3

  4. PROC PROC Phil Phil ( (CHAN INT CHAN INT thinking! thinking!, , eating! eating!, , BARRIER BARRIER eatBar eatBar) ) WHILE TRUE WHILE TRUE SEQ SEQ thinking ! 0 thinking ! 0 SYNC eatBar SYNC eatBar eating ! 0 eating ! 0 thinking thinking P P eatBar eatBar SYNC eatBar eatBar SYNC eating eating : : Phil Phil ( (thinking thinking, , eating eating, , eatBar eatBar) = ) = let let Phil_0_ = = Phil_0_ thinking - thinking -> > eatBar eatBar - -> > eating - eating -> > eatBar eatBar - -> > Phil_0_ Phil_0_ within within Phil_0_ Phil_0_ : : 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 4

  5. thinking thinking eatBar eatBar eating eating College College P P F F F F P P P P F F F F F F P P P P 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 5

  6. PROC PROC Fork Fork ( (BARRIER BARRIER eatBarRight eatBarRight, , eatBarLeft eatBarLeft) ) WHILE TRUE WHILE TRUE ALT ALT F F SYNC eatBarRight eatBarRight SYNC eatBarRight eatBarRight SYNC SYNC eatBarRight eatBarRight SYNC eatBarLeft eatBarLeft SYNC SYNC eatBarLeft eatBarLeft SYNC eatBarLeft eatBarLeft : : Fork ( (eatBarRight eatBarRight, , eatBarLeft eatBarLeft) = ) = Fork let let Fork_0_ = Fork_0_ = eatBarRight - eatBarRight -> > eatBarRight eatBarRight - -> > Fork_0_ Fork_0_ [] [] eatBarLeft - -> > eatBarLeft eatBarLeft - -> > Fork_0_ Fork_0_ eatBarLeft within within Fork_0_ Fork_0_ : : 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 6

  7. 0 0 4 4 VAL INT nPhils VAL INT nPhils IS 5: IS 5: 1 1 nPhils = 5 nPhils = 5 3 3 2 2 PROC Philosophers Philosophers ( ([ [nPhils]CHAN nPhils]CHAN INT INT thinking! thinking!, , eating! eating!, , PROC [nPhils]BARRIER nPhils]BARRIER eatBar eatBar) ) [ PAR id = 0 FOR nPhils nPhils PAR id = 0 FOR Phil ( Phil (thinking[id thinking[id]! ]!, , eating[id eating[id]! ]!, , eatBar[id eatBar[id] ]) ) : : Philosophers ( (thinking thinking, , eating eating, , eatBar eatBar) = ) = Philosophers ||| id ||| id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ Phil (thinking.id thinking.id, , eating.id eating.id, , eatBar.id eatBar.id) ) Phil ( 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 7

  8. 0 0 FDR2 uses 4 except that FDR2 4 … except that FDR2 uses much … except that … uses much much VAL INT nPhils VAL INT nPhils IS 5: IS 5: less memory and time if replicated less memory and time if replicated less memory and time if replicated (or merely repeated) processes (or merely repeated) processes (or merely repeated) processes 1 1 take no parameters nPhils = 5 nPhils no parameters, = 5 , but instead but instead take take no parameters, but instead use event renaming use event renaming to wire up the to wire up the use event renaming to wire up the 3 3 different instances. different instances. different instances. 2 2 channel thinking_r0_ VERIFY PROC Philosophers thinking_r0_, Philosophers ( , eating_r0_ eating_r0_, ([ [nPhils]CHAN nPhils]CHAN INT , eatBar_r0_ eatBar_r0_ INT thinking! thinking!, , eating! eating!, , channel VERIFY PROC [nPhils]BARRIER nPhils]BARRIER eatBar eatBar) ) [ Philosophers ( PAR id = 0 FOR nPhils (thinking thinking, nPhils , eating eating, , eatBar eatBar) = ) = Philosophers PAR id = 0 FOR let let Phil (thinking[id Phil ( thinking[id]! ]!, , eating[id eating[id]! ]!, , eatBar[id eatBar[id] ]) ) : Philosophers_0 = Phil ( (thinking_r0_ thinking_r0_, , eating_r0_ eating_r0_, , eatBar_r0_ eatBar_r0_) ) : Philosophers_0 = Phil within within ||| id id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ ||| Philosophers_0 [[ Philosophers_0 [[ Note: the three the three Note: Philosophers ( (thinking thinking, , eating eating, , eatBar eatBar) = ) = Philosophers thinking_r0_ < <- - thinking.id thinking.id, , thinking_r0_ declared channels are declared channels are ||| id ||| id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ eating_r0_ < <- - eating.id eating.id, , eating_r0_ not actually used !! not actually used !! Phil (thinking.id thinking.id, , eating.id eating.id, , eatBar.id eatBar.id) ) Phil ( eatBar_r0_ < <- - eatBar.id eatBar.id) ) eatBar_r0_ ]] ]] 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 8

  9. 0 0 4 4 VAL INT nPhils VAL INT nPhils IS 5: IS 5: 1 1 nPhils = 5 nPhils = 5 3 3 2 2 PROC Forks PROC Forks ( ([ [nPhils]BARRIER nPhils]BARRIER eatBar eatBar) ) PAR id = 0 FOR nPhils PAR id = 0 FOR nPhils VAL INT right IS id: VAL INT right IS id: VAL INT left IS (id + 1)\ \nPhils: nPhils: VAL INT left IS (id + 1) Fork ( Fork (eatBar[right eatBar[right] ], , eatBar[left eatBar[left] ]) ) : : Forks ( (eatBar eatBar) = ) = Forks || id id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ || [{ eatBar.id eatBar.id, , eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils) }] }] [{ Fork ( Fork (eatBar.id eatBar.id, , eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils)) ) 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 9

  10. 0 0 FDR2 uses 4 except that FDR2 4 … except that FDR2 uses much … except that … uses much much VAL INT nPhils VAL INT nPhils IS 5: IS 5: less memory and time if replicated less memory and time if replicated less memory and time if replicated (or merely repeated) processes (or merely repeated) processes (or merely repeated) processes 1 1 take no parameters nPhils = 5 nPhils no parameters, = 5 , but instead but instead take take no parameters, but instead use event renaming use event renaming to wire up the to wire up the use event renaming to wire up the 3 3 different instances. different instances. different instances. 2 2 Note: the two the two Note: channel eatBarRight_r2_ eatBarRight_r2_, , eatBarLeft_r2_ eatBarLeft_r2_ channel VERIFY PROC Forks VERIFY PROC Forks ( ([ [nPhils]BARRIER nPhils]BARRIER eatBar eatBar) ) declared channels are declared channels are PAR id = 0 FOR nPhils PAR id = 0 FOR nPhils not actually used !! not actually used !! Forks ( (eatBar eatBar) = ) = Forks VAL INT right IS id: VAL INT right IS id: let let VAL INT left IS (id + 1)\ \nPhils: nPhils: VAL INT left IS (id + 1) Forks_0 = Fork ( (eatBarRight_r2_ eatBarRight_r2_, , eatBarLeft_r2_ eatBarLeft_r2_) ) Forks_0 = Fork Fork Fork ( (eatBar[right eatBar[right] ], , eatBar[left eatBar[left] ]) ) within : : within || id id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ || [{ eatBar.id [{ eatBar.id, , eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils) }] }] Forks ( (eatBar eatBar) = ) = Forks Forks_0 [[ [[ Forks_0 || id id : : {0..(nPhils {0..(nPhils – – 1)} @ 1)} @ || eatBarRight_r2_ < <- - eatBar.id eatBar.id, , eatBarRight_r2_ [{ eatBar.id eatBar.id, , eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils) }] }] [{ eatBarLeft_r2_ < <- - eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils) eatBarLeft_r2_ Fork ( Fork (eatBar.id eatBar.id, , eatBar.((id eatBar.((id + 1)%nPhils) + 1)%nPhils)) ) ]] ]] 15-Oct-11 Copyleft (GPL) P.H.Welch and J.B.Pedersen 10

Recommend


More recommend