week 1 introduction to model checking
play

Week-1: Introduction to model checking B. Srivathsan Chennai - PowerPoint PPT Presentation

Week-1: Introduction to model checking B. Srivathsan Chennai Mathematical Institute NPTEL-course July - November 2015 1 / 30 Module 4: Modeling concurrent systems 2 / 30 Concurrent systems Independent Shared variables Shared actions 3 / 30


  1. Week-1: Introduction to model checking B. Srivathsan Chennai Mathematical Institute NPTEL-course July - November 2015 1 / 30

  2. Module 4: Modeling concurrent systems 2 / 30

  3. Concurrent systems Independent Shared variables Shared actions 3 / 30

  4. red TrLight 1 green red TrLight 2 green 4 / 30

  5. red TrLight 1 green red TrLight 2 green What is the transition system for the joint behaviour ? 4 / 30

  6. red TrLight 1 green red TrLight 2 green 5 / 30

  7. red TrLight 1 green red TrLight 2 green red , red 5 / 30

  8. red TrLight 1 green red TrLight 2 green red , red green , red red , green 5 / 30

  9. red TrLight 1 green red TrLight 2 green red , red green , red red , green green , green 5 / 30

  10. red TrLight 1 green red TrLight 2 green red , red green , red red , green green , green 5 / 30

  11. red TrLight 1 green red TrLight 2 green red , red green , red red , green green , green 5 / 30

  12. red TrLight 1 green red TrLight 2 green red , red TrLight 1 ||| TrLight 2 green , red red , green green , green 5 / 30

  13. red TrLight 1 green red TrLight 2 green red , red TrLight 1 ||| TrLight 2 green , red red , green ||| : Interleaving operator green , green 5 / 30

  14. q 1 l 1 y := y-2 x := x+1 ... ... y:= y-2 x:= x+1 q 2 l 2 PG 1 PG 2 6 / 30

  15. α q 1 β l 1 y := y-2 x := x+1 ... ... y:= y-2 x:= x+1 q 2 l 2 PG 1 PG 2 q 1 : y=7 l 1 : x=0 α β q 2 : y=5 l 2 : x=1 TS 1 TS 2 ( initially x=0 ) ( initially y=7 ) 6 / 30

  16. α q 1 β l 1 y := y-2 x := x+1 ... ... y:= y-2 x:= x+1 q 2 l 2 PG 1 PG 2 q 1 : y=7 l 1 : x=0 x=0 , y=7 β α α β x=1 , y=7 x=0 , y=5 α β x=1 , y=5 q 2 : y=5 l 2 : x=1 TS 1 TS 1 ||| TS 2 TS 2 ( initially x=0 ) ( initially y=7 ) 6 / 30

  17. a a q 1 q 2 ||| l 1 l 3 b a b l 2 7 / 30

  18. a a q 1 q 2 ||| l 1 l 3 b a b l 2 l 1 , q 1 l 2 , q 1 l 3 , q 1 l 1 , q 2 l 2 , q 2 l 3 , q 2 7 / 30

  19. a a q 1 q 2 ||| l 1 l 3 b a b l 2 a l 1 , q 1 l 2 , q 1 l 3 , q 1 a l 1 , q 2 l 2 , q 2 l 3 , q 2 7 / 30

  20. a a q 1 q 2 ||| l 1 l 3 b a b l 2 a b l 1 , q 1 l 2 , q 1 l 3 , q 1 a l 1 , q 2 l 2 , q 2 l 3 , q 2 7 / 30

  21. a a q 1 q 2 ||| l 1 l 3 b a b l 2 a b l 1 , q 1 l 2 , q 1 l 3 , q 1 a a a l 1 , q 2 l 2 , q 2 l 3 , q 2 7 / 30

  22. a a q 1 q 2 ||| l 1 l 3 b a b l 2 a b l 1 , q 1 l 2 , q 1 l 3 , q 1 a a a a l 1 , q 2 l 2 , q 2 l 3 , q 2 7 / 30

  23. a a q 1 q 2 ||| l 1 l 3 b a b l 2 a b l 1 , q 1 l 2 , q 1 l 3 , q 1 a a a a b b b b l 1 , q 2 l 2 , q 2 l 3 , q 2 a a 7 / 30

  24. Multiple systems TS 1 ||| TS 2 ||| ... ||| TS n 8 / 30

  25. Multiple systems TS 1 ||| TS 2 ||| ... ||| TS n Exercise: Try out an example of interleaving three systems 8 / 30

  26. Concurrent systems Independent Shared variables Interleaving TS 1 ||| TS 2 ||| ... ||| TS n Shared actions 9 / 30

  27. q 1 x:= 2 · x l 1 x:= x+1 ... ... x := 2 · x x:= x+1 q 2 l 2 PG 1 PG 2 10 / 30

  28. α q 1 x:= 2 · x β l 1 x:= x+1 ... ... x := 2 · x x:= x+1 q 2 l 2 PG 1 PG 2 q 1 : x=3 l 1 : x=3 α β q 2 : x=4 l 2 : x=6 TS 1 TS 2 ( initially x=3 ) ( initially x=3 ) 10 / 30

  29. α q 1 x:= 2 · x β l 1 x:= x+1 ... ... x := 2 · x x:= x+1 q 2 l 2 PG 1 PG 2 q 1 : x=3 l 1 : x=3 x=3 , x=3 β α α β x=6 , x=3 x=3 , x=4 α β q 2 : x=4 l 2 : x=6 x=6 , x=4 TS 1 TS 1 ||| TS 2 TS 2 ( initially x=3 ) ( initially x=3 ) 10 / 30

  30. q 1 l 1 x := 2 · x x := x+1 q 2 l 2 PG 1 PG 2 11 / 30

  31. l 1 , q 1 q 1 l 1 x:=2 · x x:=x+1 ||| x := 2 · x l 2 , q 1 l 1 , q 2 x := x+1 = q 2 l 2 x:=2 · x x:=x+1 l 2 , q 2 PG 1 PG 2 PG 1 ||| PG 2 11 / 30

  32. l 1 , q 1 α q 1 β l 1 x:=2 · x x:=x+1 ||| x := 2 · x l 2 , q 1 l 1 , q 2 x := x+1 = q 2 l 2 x:=2 · x x:=x+1 l 2 , q 2 PG 1 PG 2 PG 1 ||| PG 2 l 1 , q 1 : x=3 β α TS( PG 1 ||| PG 2 ): l 2 , q 1 : x=6 l 1 , q 2 : x=4 β α l 2 , q 2 : x=7 l 2 , q 2 : x=8 11 / 30

  33. Concurrent systems Independent Shared variables Interleaving TS( PG 1 ||| PG 2 ||| ... ||| PG n ) TS 1 ||| TS 2 ||| ... ||| TS n Shared actions 12 / 30

  34. Coming next: Another example 13 / 30

  35. while x < 200 while x>0 while x=200 x := x+1 x := x-1 x := 0 14 / 30

  36. while x < 200 while x>0 while x=200 x := x+1 x := x-1 x := 0 Is the value of x always between 0 and 200? 14 / 30

  37. while x < 200 while x>0 while x=200 x := x+1 x := x-1 x := 0 m 1 n 1 l 1 x := x+1 x < 200 x:=x-1 x > 0 x:=0 x = 200 m 2 n 2 l 2 Is the value of x always between 0 and 200? 14 / 30

  38. l 1 , m 1 , n 1 x:=x+1 x=200 x:=x-1 x>0 x:=0 x<200 l 2 , m 1 , n 1 l 1 , m 2 , n 1 l 1 , m 1 , n 2 x=200 x:=x+1 x<200 x:=x-1 x>0 x:=x-1 x>0 x=200 x:=x+1 x:=0 x<200 x:=0 l 2 , m 2 , n 1 l 2 , m 1 , n 2 l 1 , m 2 , n 2 x=200 x:=x+1 x:=x-1 x>0 x:=0 x<200 l 2 , m 2 , n 2 15 / 30

  39. l 1 , m 1 , n 1 x:=x+1 x=200 x:=x-1 x>0 x:=0 x<200 l 2 , m 1 , n 1 l 1 , m 2 , n 1 l 1 , m 1 , n 2 x=200 x:=x+1 x<200 x:=x-1 x>0 x:=x-1 x>0 x=200 x:=x+1 x:=0 x<200 x:=0 l 2 , m 2 , n 1 l 2 , m 1 , n 2 l 1 , m 2 , n 2 x=200 x:=x+1 x:=x-1 x>0 x:=0 x<200 l 2 , m 2 , n 2 15 / 30

  40. l 1 , m 1 , n 1 x:=x+1 x=200 x:=x-1 x>0 x:=0 x<200 l 2 , m 1 , n 1 l 1 , m 2 , n 1 l 1 , m 1 , n 2 x=200 x:=x+1 x<200 x:=x-1 x>0 x:=x-1 x>0 x=200 x:=x+1 x:=0 x<200 x:=0 l 2 , m 2 , n 1 l 2 , m 1 , n 2 l 1 , m 2 , n 2 x=200 x:=x+1 x:=x-1 x>0 x:=0 x<200 l 2 , m 2 , n 2 Is the value of x always between 0 and 200? No 15 / 30

  41. Coming next: Mutual exclusion 16 / 30

  42. ... P 1 P 2 P n S HARED R ESOURCE (variable, printer, ... ) Mutual Exclusion: No two processes can access the resource simultaneously 17 / 30

  43. Goal: Modeling the protocols used for mutual exclusion 18 / 30

  44. P 1 P 2 loop forever loop forever . . . . *non-critical actions* *non-critical actions* . . request request critical section critical section release release . . . . *non-critical actions* *non-critical actions* . . end loop end loop 19 / 30

  45. P 1 P 2 loop forever loop forever . . . . *non-critical actions* *non-critical actions* . . request request critical section critical section release release . . . . *non-critical actions* *non-critical actions* . . end loop end loop PG 1 PG 2 noncrit 1 noncrit 2 wait 1 wait 2 crit 1 crit 2 19 / 30

  46. P 1 P 2 loop forever loop forever . . . . *non-critical actions* *non-critical actions* . . 〈 if y>0 : y:=y-1 〉 〈 if y>0 : y:=y-1 〉 *request* *request* critical section critical section y:=y+1 y:=y+1 *release* *release* . . . . *non-critical actions* *non-critical actions* . . end loop end loop PG 1 PG 2 noncrit 1 noncrit 2 wait 1 wait 2 y:= y+1 y:= y+1 y>0:y:=y-1 y>0:y:=y-1 crit 1 crit 2 19 / 30

  47. P 1 P 2 loop forever loop forever . . . . *non-critical actions* *non-critical actions* . . 〈 if y>0 : y:=y-1 〉 〈 if y>0 : y:=y-1 〉 *request* *request* critical section critical section y:=y+1 y:=y+1 *release* *release* . . . . *non-critical actions* *non-critical actions* . . end loop end loop PG 1 PG 2 noncrit 1 noncrit 2 atomic wait 1 wait 2 y:= y+1 y:= y+1 y>0:y:=y-1 y>0:y:=y-1 crit 1 crit 2 19 / 30

  48. PG 1 ||| PG 2 noncrit 1 , noncrit 2 y:=y+1 y:=y+1 wait 1 , noncrit 2 noncrit 1 , wait 2 y:=y+1 y>0: y>0: y:=y-1 y:=y-1 crit 1 , noncrit 2 wait 1 , wait 2 noncrit 1 , crit 2 y>0: crit 1 , wait 2 wait 1 , crit 2 y:=y-1 y:=y+1 y:=y+1 crit 1 , crit 2 20 / 30

  49. TS( PG 1 ||| PG 2 ) n 1 , n 2 , y=1 w 1 , n 2 , y=1 n 1 , w 2 , y=1 c 1 , n 2 , y=0 w 1 , w 2 , y=1 n 1 , c 2 , y=0 c 1 , w 2 , y=0 w 1 , c 2 , y=0 21 / 30

  50. TS( PG 1 ||| PG 2 ) n 1 , n 2 , y=1 w 1 , n 2 , y=1 n 1 , w 2 , y=1 c 1 , n 2 , y=0 w 1 , w 2 , y=1 n 1 , c 2 , y=0 c 1 , w 2 , y=0 w 1 , c 2 , y=0 Both processes cannot be in critical section simultaneously 21 / 30

  51. Concurrent systems Independent Shared variables Interleaving TS( PG 1 ||| PG 2 ||| ... ||| PG n ) TS 1 ||| TS 2 ||| ... ||| TS n Mutual Exclusion Shared actions 22 / 30

  52. Coming next: Book-keeping system in a supermarket 23 / 30

  53. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 24 / 30

  54. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 000 24 / 30

  55. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 scan 100 000 24 / 30

  56. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 scan 100 000 check_price 010 24 / 30

  57. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 scan 100 000 001 prt_cmd check_price 010 24 / 30

  58. Bar-Code Reader (BCR) Booking Program (BP) Printer (P) 0 0 0 scan print check_price print_cmd check_price print_cmd 1 1 1 101 print check_price scan prt_cmd print print scan scan 100 000 001 110 111 011 scan prt_cmd print check_price 010 24 / 30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend