blob: 044cde1ef2032e2ecfb9aa4e628a7452fe332e01 (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// RUN: %boogie -noinfer -typeEncoding:m -useArrayTheory %s > %t
// RUN: %diff %s.expect %t
var {:phase 2} b: bool;
procedure {:yields} {:phase 2} main()
{
yield;
while (*)
{
yield;
async call Customer();
yield;
}
}
procedure {:yields} {:phase 2} Customer()
{
yield;
while (*)
{
yield;
call Enter();
yield;
call Leave();
yield;
}
}
procedure {:yields} {:phase 1,2} Enter()
ensures {:atomic} |{ A: assume !b; b := true; return true; }|;
{
var status: bool;
yield;
L:
call status := CAS(false, true);
yield;
goto A, B;
A:
assume status;
yield;
return;
B:
assume !status;
goto L;
}
procedure {:yields} {:phase 0,2} CAS(prev: bool, next: bool) returns (status: bool);
ensures {:atomic} |{
A: goto B, C;
B: assume b == prev; b := next; status := true; return true;
C: status := false; return true;
}|;
procedure {:yields} {:phase 0,2} Leave();
ensures {:atomic} |{ A: b := false; return true; }|;
|