summaryrefslogtreecommitdiff
path: root/Test/civl/parallel1.bpl
blob: 20dd3c79edfd8eee3319a7940d392aed6993ba79 (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
// RUN: %boogie -noinfer "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var {:layer 0,1} g:int;

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

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

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

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

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

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