summaryrefslogtreecommitdiff
path: root/Test/og/parallel1.bpl
blob: 90846b6c083d22e6f5a0c5710459a08096216a8f (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
// RUN: %boogie -noinfer %s > %t
// RUN: %diff %s.expect %t
var {:phase 1} g:int;

procedure {:yields} {:phase 1} PB()
{
  yield;
  call Incr();
  yield;
}

procedure {:yields} {:phase 0,1} Incr();
ensures {:atomic}
|{A:
  g := g + 1; return true;
}|;

procedure {:yields} {:phase 0,1} Set(v: int);
ensures {:atomic}
|{A:
  g := v; return true;
}|;

procedure {:yields} {:phase 1} PC()
ensures {:phase 1} g == 3;
{
  yield;
  call Set(3);
  yield;
  assert {:phase 1} g == 3;
}

procedure {:yields} {:phase 1} PD()
{
  call PC();
  assert {:phase 1} g == 3;
  yield;
}

procedure {:yields} {:phase 1} Main()
{
  yield;
  while (*)
  {
    par PB() | PC() | PD();
  }
}