blob: db5c4b1a91865f48e56bf0103eaa9b53e3c8f0ac (
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
|
// RUN: %boogie "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
procedure LockingExample();
implementation LockingExample()
{
var x: int;
var y: int;
var held: int;
start:
held := 0;
x := 0;
goto LoopHead;
LoopHead:
// Lock
held := held + 6;
assert held == 0;
held := 1;
y := x;
goto UnlockNow, LoopEnd;
UnlockNow:
// Unlock
assert held == 1;
held := 0;
x := x + 1;
goto LoopEnd;
LoopEnd:
goto ContinueIteration, EndIteration;
ContinueIteration:
assume x != y;
goto LoopHead;
EndIteration:
assume x == y;
goto AfterLoop;
AfterLoop:
// Unlock
assert held == 1;
held := 0;
return;
}
|