1 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching15-398 SPIN Examples.

Slides:



Advertisements
Similar presentations
TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Advertisements

You have been given a mission and a code. Use the code to complete the mission and you will save the world from obliteration…
Using Matrices in Real Life
Advanced Piloting Cruise Plot.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Properties Use, share, or modify this drill on mathematic properties. There is too much material for a single class, so you’ll have to select for your.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
Multiplying binomials You will have 20 seconds to answer each of the following multiplication problems. If you get hung up, go to the next problem when.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 5 second questions
Year 6 mental test 10 second questions
2010 fotografiert von Jürgen Roßberg © Fr 1 Sa 2 So 3 Mo 4 Di 5 Mi 6 Do 7 Fr 8 Sa 9 So 10 Mo 11 Di 12 Mi 13 Do 14 Fr 15 Sa 16 So 17 Mo 18 Di 19.
ZMQS ZMQS
Richmond House, Liverpool (1) 26 th January 2004.
REVIEW: Arthropod ID. 1. Name the subphylum. 2. Name the subphylum. 3. Name the order.
ABC Technology Project
1 Undirected Breadth First Search F A BCG DE H 2 F A BCG DE H Queue: A get Undiscovered Fringe Finished Active 0 distance from A visit(A)
VOORBLAD.
15. Oktober Oktober Oktober 2012.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
“Start-to-End” Simulations Imaging of Single Molecules at the European XFEL Igor Zagorodnov S2E Meeting DESY 10. February 2014.
BIOLOGY AUGUST 2013 OPENING ASSIGNMENTS. AUGUST 7, 2013  Question goes here!
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
Squares and Square Root WALK. Solve each problem REVIEW:
Basel-ICU-Journal Challenge18/20/ Basel-ICU-Journal Challenge8/20/2014.
1..
© 2012 National Heart Foundation of Australia. Slide 2.
Lets play bingo!!. Calculate: MEAN Calculate: MEDIAN
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Chapter 5 Test Review Sections 5-1 through 5-4.
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Addition 1’s to 20.
25 seconds left…...
Slippery Slope
H to shape fully developed personality to shape fully developed personality for successful application in life for successful.
Januar MDMDFSSMDMDFSSS
Week 1.
Analyzing Genes and Genomes
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Intracellular Compartments and Transport
A SMALL TRUTH TO MAKE LIFE 100%
PSSA Preparation.
VPN AND REMOTE ACCESS Mohammad S. Hasan 1 VPN and Remote Access.
Immunobiology: The Immune System in Health & Disease Sixth Edition
Essential Cell Biology
1 Chapter 13 Nuclear Magnetic Resonance Spectroscopy.
Immunobiology: The Immune System in Health & Disease Sixth Edition
McGraw-Hill©The McGraw-Hill Companies, Inc., 2001 Chapter 16 Integrated Services Digital Network (ISDN)
CpSc 3220 Designing a Database
Traktor- og motorlære Kapitel 1 1 Kopiering forbudt.
© 2011 Carnegie Mellon University SPIN: Part Bug Catching: Automated Program Verification and Testing Sagar Chaki November 2, 2011.
Presentation transcript:

1 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching SPIN Examples

2 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem

3 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem

4 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1

5 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0

6 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1

7 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1

8 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1

9 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 Critical Section

10 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section

11 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion Peterson’s solution to the mutual exclusion problem flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section

12 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section proctype mutex0() { }

13 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; proctype mutex0() { }

14 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { }

15 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { flag[0] = 1; }

16 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { flag[0] = 1; turn = 0; }

17 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { flag[0] = 1; turn = 0; (flag[1] == 0 || turn == 0); }

18 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { flag[0] = 1; turn = 0; (flag[1] == 0 || turn == 0); /* critical section */ }

19 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { flag[0] = 1; turn = 0; (flag[1] == 0 || turn == 0); /* critical section */ flag[0] = 0; }

20 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN flag 0 =1 turn=0 flag 1 == 0 || turn == 1 flag 1 != 0 && turn != 1 flag 0 =0 Critical Section bool turn; bool flag[2]; proctype mutex0() { again: flag[0] = 1; turn = 0; (flag[1] == 0 || turn == 0); /* critical section */ flag[0] = 0; goto again; }

21 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN bool turn, flag[2]; active [2] proctype user() { assert(_pid == 0 || __pid == 1); again: flag[_pid] = 1; turn = _pid; (flag[1 - _pid] == 0 || turn == 1 - _pid); /* critical section */ flag[_pid] = 0; goto again; } Active process: automatically creates instances of processes _pid: Identifier of the process assert: Checks that there are only at most two instances with identifiers 0 and 1

22 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN bool turn, flag[2]; byte ncrit; active [2] proctype user() { assert(_pid == 0 || __pid == 1); again: flag[_pid] = 1; turn = _pid; (flag[1 - _pid] == 0 || turn == 1 - _pid); ncrit++; assert(ncrit == 1); /* critical section */ ncrit--; flag[_pid] = 0; goto again; } ncrit: Counts the number of Process in the critical section assert: Checks that there are always at most one process in the critical section

23 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Mutual Exclusion in SPIN bool turn, flag[2]; bool critical[2]; active [2] proctype user() { assert(_pid == 0 || __pid == 1); again: flag[_pid] = 1; turn = _pid; (flag[1 - _pid] == 0 || turn == 1 - _pid); critical[_pid] = 1; /* critical section */ critical[_pid] = 0; flag[_pid] = 0; goto again; } LTL Properties: [] (critial[0] || critical[1]) [] <> (critical[0]) [] <> (critical[1]) [] (critical[0] -> (critial[0] U (!critical[0] && ((!critical[0] && !critical[1]) U critical[1])))) [] (critical[1] -> (critial[1] U (!critical[1] && ((!critical[1] && !critical[0]) U critical[0]))))

24 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Alternating Bit Protocol Two processes want to communicate They want acknowledge of received messages Sending window of one message Each message is identified by one bit Alternating values of the identifier

25 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Alternating Bit Protocol SenderReceiver msg0 ack0 msg1 ack1 msg0 ack0 msg1

26 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Alternating Bit Protocol SenderReceiver msg0 ack1 msg0 ack0

27 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Alternating Bit Protocol SenderReceiver msg0 ack0 msg1 ack1 msg0

28 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Sender Process active proctype Sender() { do :: if :: receiver?msg0; :: skip fi; do :: sender?ack0 -> break :: sender?ack1 :: timeout -> if :: receiver!msg0; :: skip fi; od; :: if :: receiver?msg1; :: skip fi; do :: sender?ack1 -> break :: sender?ack0 :: timeout -> if :: receiver!msg1; :: skip fi; od; }

29 Carnegie Mellon UniversitySPIN ExamplesFlavio Lerda Bug Catching Receiver Process active proctype Receiver() { do :: do :: receiver?msg0 -> sender!ack0; break; :: receiver?msg1 -> server!ack1 od do :: receiver?msg1 -> sender!ack1; break; :: receiver?msg0 -> server!ack0 od } mtype = { msg0, msg1, ack0, ack1 } chan sender = [1] of { mtype }; chan receiver = [1] of { mtype };