SYSTEM DEADLOCKS - DINING PHILOSOPHERS - - PDF document

system deadlocks dining philosophers
SMART_READER_LITE
LIVE PREVIEW

SYSTEM DEADLOCKS - DINING PHILOSOPHERS - - PDF document

dependability engineering & Petri nets May 2005 SYSTEM DEADLOCKS - DINING PHILOSOPHERS D:\mh\docs\lv\nl\nl_skript\nl07_deadlock_phils.sld.fm 7 - 1 / 20 dependability engineering & Petri nets May 2006 DINING PHILOSOPHERS , ONE


slide-1
SLIDE 1

dependability engineering & Petri nets May 2005 D:\mh\docs\lv\nl\nl_skript\nl07_deadlock_phils.sld.fm 7 - 1 / 20

SYSTEM DEADLOCKS

  • DINING

PHILOSOPHERS

slide-2
SLIDE 2

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 2 / 20

DINING PHILOSOPHERS, ONE PHILOSOPHER PN COMPONENT

right_fork left_fork phil right_fork left_fork thinking take_left waiting take_right put_left releasing put_right eating left_fork right_fork

ORD HOM NBM PUR CSV SCF CON SC Ft0 tF0 Fp0 pF0 MG SM FC EFC ES Y Y Y Y N Y Y Y N N N N Y N Y Y Y DTP SMC SMD SMA CPI CTI B SB REV DSt BSt DTr DCF L LV L&S Y Y Y Y Y Y Y Y Y N ? N Y Y Y Y

slide-3
SLIDE 3

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 3 / 20

DINING PHILOSOPHERS, SYSTEM OF N PHILOSOPHERS

fork4 fork5 phil5 fork2 fork3 fork1 phil5 phil4 phil2 phil3 phil1 phil3 fork2 fork3 fork1 phil2 phil3 phil1 fork4 phil4 fork2 fork3 fork1 phil4 phil2 phil3 phil1

ORD HOM NBM PUR CSV SCF CON SC Ft0 tF0 Fp0 pF0 MG SM FC EFC ES Y Y Y Y N N Y Y N N N N N N N N Y DTP SMC SMD SMA CPI CTI B SB REV DSt BSt DTr DCF L LV L&S N Y Y N Y Y Y Y N Y ? N N N N N

slide-4
SLIDE 4

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 4 / 20

DINING PHILOSOPHERS (2 PHILS), REACHABILITY GRAPH

th1, th2, f1, f2 w1, th2, f2 th1, w2, f1 w1, w2 e1, th2 r1, th2, f2 r1, w2 th1, e2 th1, r2, f1 w1, r2 tl1 tl2 tl2 tl1 tr1 pr1 tl2 pl1 pl1 pl2 tl1 pr2 tr2 pl2

slide-5
SLIDE 5

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 5 / 20

DINING PHILOSOPHERS (2 PHILS), STUBBORN SET REDUCED REACHABILITY GRAPH

r1, w2 w1, r2 th1, th2, f1, f2 w1, th2, f2 th1, w2, f1 w1, w2 e1, th2 r1, th2, f2 th1, e2 th1, r2, f1 tl1 tl2 tl2 tl1 tr1 pr1 tl2 pl1 pl1 pl2 tl1 pr2 tr2 pl2

slide-6
SLIDE 6

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 6 / 20

DINING PHILOSOPHERS (2 PHILS), CONCURRENT AUTOMATON

th1, th2, f1, f2 w1, th2, f2 th1, w2, f1 w1, w2 r1, th2, f2 th1, r2, f1 tl1 tl2 {tr1; pr1} pl1 {pl1 | {tl1 | {tr2; pr2} pl2 {tl1 | tl2} th1, th2, f1, f2 w1, w2 {tl1 | tl2} {tl1; tr1; pr1; pl1} {tl2; tr2; pr2; pl2} tl2} pl2}

??

slide-7
SLIDE 7

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 7 / 20

DINING PHILOSOPHERS (2 PHILS), FINITE PREFIX OF BRANCHING PROCESSES

fork1 (B17) fork2 (B15) fork1 (B11) fork2 (B9) fork2 (B2) fork1 (B1) waiting2 (B13) take_left2 (E9) waiting1 (B14) take_left1 (E10) thinking1 (B18) thinking2 (B16) thinking2 (B4) take_left2 (E2) waiting2 (B6) take_right2 (E4) put_left2 (E8) releasing2 (B12) put_right2 (E6) eating2 (B8) thinking1 (B3) take_left1 (E1) waiting1 (B5) take_right1 (E3) put_left1 (E7) releasing1 (B10) put_right1 (E5) eating1 (B7)

slide-8
SLIDE 8

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 8 / 20

DINING PHILOSOPHERS, ANALYSIS EFFORTS WITH INA/PROD

# phils P / T Rstub R B / E time 1 2 3 4 5 6 / 4 10 / 8 15 / 12 20 / 16 25 / 20 4 8 20 38 62 4 10 35 118 392 9 / 4 18 / 10 45 / 27 84 / 52 135 / 85 6 7 8 9 10 30 / 24 35 / 28 40 / 32 45 / 36 50 / 40 92 128 170 218 272 1.297 4.286 14.158 46.763 154.450 198 / 126 273 / 175 360 / 232 459 / 297 570 / 370 11 12 13 14 15 55 / 44 60 / 48 65 / 52 70 / 56 75 / 60 332 398 470 548 632 510.116 (5.56 e+6) (60.7 e+6) 693 / 451 828 / 540 975 / 637 1.134 / 742 1.305 / 855 (0 : 5) (0 : 23) (1 : 29) (6 : 28) (27 : 42)

PEP INA

slide-9
SLIDE 9

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 9 / 20

DINING PHILOSOPHERS, ANALYSIS EFFORTS WITH SMV (BDD)

Machine: Hypersparc, 32 MB (britten) Times: user time + system time Model checking of the formula AG(_fork1 | _fork2 | ... | forkn)

  • Comp. of variable reordering perfomed without model checking

smv options: -f -r inc

# states without reordering computation of reordering with reordering time BDD nodes time BDD nodes time BDD nodes 2 10 0.1” 3120 0.06” 1405 0.1” 3082 3 35 0.17” 7577 0.11” 3895 0.17” 7474 5 392 0.68” 10258 0.87” 5186 0.28” 10037 7 4247 3.09” 12635 5.36” 8800 2.82” 12674 9 46763 16.95” 60310 27.99” 12836 6.16” 16533 11 510116 88.17” 200803 5.99’ 49459 25.75” 67469 13 5.56e+6 35.99’ 720848 28.10’ 165055 1.69’ 222471 15 60.7e+6 1.76 h 1369156 41.12’ 125471 1.93’ 160109

slide-10
SLIDE 10

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 10 / 20

PHIL1000, BDD-BASED BY JSP Number of states:

1137517608656205162806720354362767684058541876947800011092858232169918\\ 1599595881220313326411206909717907134074139603793701320514129462357710\\ 2442895227384242418853247239522943007188808619270527555972033293948691\\ 3344982712874090358789533181711372863591957907236895570937383074225421\\ 4932997350559348711208726085116502627818524644762991281238722816835426\\ 4390437022222227167126998740049615901200930144970216630268925118631696\\ 7921927977564308540767556777224220660450294623534355683154921949034887\\ 4138935108726115227535084646719457353408471086965332494805497753382942\\ 1717811011687720510211541690039211766279956422929032376885414750385275\\ 51248819240105363652551190474777411874

  • ca. 1.1 * 10^667

❑ Number of places/marked places/transitions: 7000/2000/5000 ❑ Time to compute P-Invariants: 45885.66 sec ❑ Number of P-Invariants: 3000 ❑ Time to compute compact coding: 385.59 sec ❑ Number of Clusters: 3000 ❑ Number of Variables: 4000 ❑ Time: 3285.73 sec, ca. 54.75 min

slide-11
SLIDE 11

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 11 / 20

DINING PHILOSOPHERS, VERSION2

ONE PHILOSOPHER PN COMPONENT

right_fork left_fork phil

ORD HOM NBM PUR CSV SCF CON SC Ft0 tF0 Fp0 pF0 MG SM FC EFC ES Y Y Y Y N Y Y Y N N N N Y N Y Y Y DTP SMC SMD SMA CPI CTI B SB REV DSt BSt DTr DCF L LV L&S Y Y Y Y Y Y Y Y Y N ? N Y Y Y Y

right_fork left_fork end_put released_left put_left releasing_right releasing_left begin_put eating end_take having_left waiting_right waiting_left begin_take thinking take_left take_right released_right put_right having_right

slide-12
SLIDE 12

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 12 / 20

DINING PHILOSOPHERS, VERSION2 ANALYSIS EFFORTS WITH INA/PEP

# phils P / T Rstub R B / E time 1 2 3 4 5 12 / 8 22 / 6 33 / 24 44 / 32 8 18 43 100 10 57 446 3429 6 7 8 9 10 11 12 13 14 15

PEP INA

slide-13
SLIDE 13

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 13 / 20

FOUR NECESSARY & SUFFICIENT DEADLOCK CONDITIONS

[COFFMAN ET AL]

mutually exclusive resources

  • >

shared, serially reusable

  • >

unsufficient supply, therefore competition

incremental acquisition

  • >

dynamic resource allocation (in opposite to static one)

  • >

processes hold resources while waiting to acquire additonal ones

no pre-emption

  • >

resources cannot be pre-empted (withdrawn forcibly)

  • >

resources are only released voluntarily

waiting cycle

  • >

cycle of processes such that each process holds a resource which its neighbour is waiting for

  • >

may contain

  • > all (total deadlock) or
  • > only some of the processes (partial deadlock)

ANY DEADLOCK AVOIDANCE POLICY HAS TO ERASE AT LEAST ONE OF THESE CONDITIONS

slide-14
SLIDE 14

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 14 / 20

DINING PHILOSOPHERS, DEADLOCK AVOIDANCE STRATEGIES ❑

limit number of phils trying to eat, so there will be enough resources for at least one

  • >

limit number of chairs

  • >

token ring protocol (only one phil can eat at any time)

  • >

sequential eating (special token ring) =>> sufficient supply, no competition

static allocation (all or nothing) =>> no incremental acquisition BUT: atomic operation to aquire multiple resources

wait only finite time =>> pre-emption, voluntarily

asymmetric behaviour

  • >
  • nly one behaves asymmetrically
  • >

even/odd-numbered phils behave differently

  • >

hierachical resource allocation =>> no waiting cycle BUT: contradiction to original task (identical pattern for all)

slide-15
SLIDE 15

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 15 / 20

DINING PHILOSOPHERS, ONE PHILOSOPHER PN COMPONENT

right_fork left_fork phil right_fork left_fork thinking take_left waiting take_right put_left releasing put_right eating left_fork right_fork

ORD HOM NBM PUR CSV SCF CON SC Ft0 tF0 Fp0 pF0 MG SM FC EFC ES Y Y Y Y N Y Y Y N N N N Y N Y Y Y DTP SMC SMD SMA CPI CTI B SB REV DSt BSt DTr DCF L LV L&S Y Y Y Y Y Y Y Y Y N ? N Y Y Y Y

slide-16
SLIDE 16

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 16 / 20

DINING PHILOSOPHERS, AS COLOURED PN (1)

forks forks thinking take_left waiting take_right put_left releasing put_right eating forks phil1 phil2 phil3

p1 p2 p3

x x x x x x x x colour(thinking) = ... = colour(releasing) = {p1, p2, p3} left(x) right(x) right(x) left(x)

f1f2 f3

colour(forks) = {f1, f2, f3} colour(take_left) = ... = colour(put_left) = {p1, p2, p3}

f1f2 f3 f1f2 f3 f1f2 f3

forks left(x) = x right(x) = (x mod n) + 1

slide-17
SLIDE 17

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 17 / 20

DINING PHILOSOPHERS, AS COLOURED PN (2)

forks thinking take_left waiting take_right put_left releasing put_right eating x x x x x x x x left(x) right(x) right(x) left(x)

p1 p2 p3 f1f2 f3

  • > net scheme for any number of philosophers
slide-18
SLIDE 18

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 18 / 20

COLOURED PETRI NETS, EXAMPLE2

2p 1m 1p+3b+2m 1ps 1fs 1md fruits prep_p_salat prep_fruit_salat prep_mango_dip healthy_dishes (2) (3) (2) mango_dip fruit-salat p_salat prep_mango_dip prep_fruit_salat prep_p_salat mango bananas papaya 2p 4b 2m prep_p_salat prep_fruit_salat prep_mango_dip edibles edibles preps

slide-19
SLIDE 19

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 19 / 20

COLOURED PETRI NETS, BASICS ❑ information-preserving transformation processes ❑ folding needs user interaction ❑ trivial transformation:

  • nly one color (black color)
  • >

no structure compression ❑ any Petri net may be transformed into

  • >

all structure information in arc inscriptions ❑ readability depends on readability of arc inscription

folding

Petrinetz

Petri net

unfolding

Petrinetz

colored Petri net

slide-20
SLIDE 20

dependability engineering & Petri nets May 2006 monika.heiner@informatik.tu-cottbus.de 20 / 20

COLOURED PETRI NETS, ANALYSIS ❑ by unfolding

  • >

reuse of all P/T net analysis techniques

  • >

symmetrically reduced rg ❑ without unfolding

  • >

reachability graph (CPN - occurrence graph)

  • >

invariants (tools ?)

  • >

CTL model checking (tools ?) ❑ dedicated notion of liveness: collectively live transitions

  • >

all transition colours of a given coloured transition guarantee together the liveness

  • >

very useful for control flow models