-
Notifications
You must be signed in to change notification settings - Fork 0
/
semaphore.smv
37 lines (32 loc) · 977 Bytes
/
semaphore.smv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
MODULE main
VAR
semaphore : boolean;
proc1 : process user(semaphore);
proc2 : process user(semaphore);
ASSIGN
init(semaphore) := FALSE;
SPEC AG ! (proc1.state = critical & proc2.state = critical)
SPEC AG (proc1.state = entering -> AF proc1.state = critical)
SPEC EF !(proc1.state = critical & proc2.state = critical)
MODULE user(semaphore)
VAR
state : {idle, entering, critical, exiting};
ASSIGN
init(state) := idle;
next(state) :=
case
state = idle : {idle, entering};
state = entering & !semaphore : critical;
state = critical : {critical, exiting};
state = exiting : idle;
TRUE : state;
esac;
next(semaphore) :=
case
state = entering : TRUE;
state = exiting : FALSE;
TRUE : semaphore;
esac;
JUSTICE
state = critical
-- running