summaryrefslogtreecommitdiff
path: root/Test/og/parallel5.bpl
blob: c583cb3c032978892ce9d26721a0147c295cb75f (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
var a:[int]int;

procedure Allocate() returns ({:linear "tid"} xls: int);

procedure {:entrypoint} main() 
{
    var {:linear "tid"} i: int;
    var {:linear "tid"} j: int;
    call i := Allocate();
    call j := Allocate();
    call i := t(i) | j := Yield(j);
    call i := u(i) | j := u(j);
}

procedure t({:linear "tid"} i': int) returns ({:linear "tid"} i: int)
{
    i := i';

    a[i] := 42;
    call i := Yield(i);
    assert a[i] == 42;
}

procedure u({:linear "tid"} i': int) returns ({:linear "tid"} i: int) 
{
    i := i';

    a[i] := 42;
    yield;
    assert a[i] == 42;
}

procedure Yield({:linear "tid"} i': int) returns ({:linear "tid"} i: int)
ensures i == i';
ensures old(a)[i] == a[i];
{
    i := i';
    yield;
    assert old(a)[i] == a[i];
}