Exemplo n.º 1
0
 def join2(self, t1: Thread, t2: Thread) -> None:
     Requires(t1 is not t2)
     Requires(getMethod(t1) == Clazz.readX)
     Requires(getMethod(t2) == Clazz.readX)
     Requires(getArg(t1, 0) is self)
     Requires(getArg(t2, 0) is self)
     Requires(Joinable(t1))
     Requires(Joinable(t2))
     Requires(Acc(ThreadPost(t1)))
     Requires(Acc(ThreadPost(t2)))
     Requires(WaitLevel() < Level(t1))
     Requires(WaitLevel() < Level(t2))
     Ensures(Acc(self.x, getARP(t1) + getARP(t2)))
     t1.join(self.readX)
     t2.join(self.readX)
Exemplo n.º 2
0
def client_fork_wrong_thread_post(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == Cell.incr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    #:: ExpectedOutput(postcondition.violated:insufficient.permission)
    Ensures(Acc(ThreadPost(t)))
    t.start(decr, Cell.incr)
Exemplo n.º 3
0
def thread_join_wrong_level(t: Thread, cl: Cell) -> None:
    Requires(getMethod(t) == decr)
    Requires(getArg(t, 0) is cl)
    Requires(getArg(t, 1) is 7)
    Requires(getOld(t, arg(0).val) is 123)
    Requires(Acc(ThreadPost(t)))
    #:: ExpectedOutput(thread.join.failed:wait.level.invalid)
    t.join(Cell.incr, decr)
Exemplo n.º 4
0
 def join1(self, t: Thread) -> None:
     Requires(getMethod(t) == Clazz.readX)
     Requires(getArg(t, 0) is self)
     Requires(Joinable(t))
     Requires(Acc(ThreadPost(t), 1))
     Requires(Acc(self.x, 1 - getARP(t)))
     Requires(WaitLevel() < Level(t))
     Ensures(Acc(self.x))
     t.join(self.readX)
Exemplo n.º 5
0
def client_fork_join_perms(t: Thread, b: bool, cell: Cell) -> None:
    Requires(Acc(MayStart(t)))
    Requires(getMethod(t) == decr)
    Requires(Acc(cell.val))
    Requires(cell is getArg(t, 0))
    Ensures(Joinable(t))
    Ensures(Acc(ThreadPost(t)))
    #:: ExpectedOutput(postcondition.violated:assertion.false)
    Ensures(False)
    t.start(decr, Cell.incr)
Exemplo n.º 6
0
def thread_join_wrong_method(t: Thread, cl: Cell) -> None:
    Requires(getMethod(t) == Cell.incr)
    Requires(getArg(t, 0) is cl)
    Requires(getArg(t, 1) is 7)
    Requires(getOld(t, arg(0).val) is 123)
    Requires(Acc(ThreadPost(t)))
    Requires(WaitLevel() < Level(t))
    t.join(decr)
    #:: ExpectedOutput(assert.failed:insufficient.permission)
    assert cl.val == 116
Exemplo n.º 7
0
def thread_join_part_perm(t: Thread, cl: Cell) -> None:
    Requires(getMethod(t) == decr)
    Requires(getArg(t, 0) is cl)
    Requires(getArg(t, 1) is 7)
    Requires(getOld(t, arg(0).val) is 123)
    Requires(Acc(ThreadPost(t), 1 / 2))
    Requires(WaitLevel() < Level(t))
    t.join(Cell.incr, decr)
    assert cl.val == 116
    #:: ExpectedOutput(assignment.failed:insufficient.permission)
    cl.val = 11
Exemplo n.º 8
0
def thread_join_pred_partial(t: Thread, cl: Cell) -> None:
    Requires(getMethod(t) == decr_pred)
    Requires(getArg(t, 0) is cl)
    Requires(getArg(t, 1) is 7)
    Requires(getOld(t, arg(0).val) is 123)
    Requires(Acc(ThreadPost(t), 1 / 2))
    Requires(WaitLevel() < Level(t))
    Ensures(Joinable(t))
    t.join(decr, decr_pred)
    Unfold(Acc(cell_pred(cl, 116), 1 / 2))
    assert cl.val == 116
    #:: ExpectedOutput(unfold.failed:insufficient.permission)
    Unfold(Acc(cell_pred(cl, 116), 1 / 2))
Exemplo n.º 9
0
def thread_join_pred(t: Thread, cl: Cell) -> None:
    Requires(getMethod(t) == decr_pred)
    Requires(getArg(t, 0) is cl)
    Requires(getArg(t, 1) is 7)
    Requires(getOld(t, arg(0).val) is 123)
    Requires(Acc(ThreadPost(t)))
    Requires(WaitLevel() < Level(t))
    Ensures(Joinable(t))
    #:: ExpectedOutput(postcondition.violated:assertion.false)
    Ensures(False)
    t.join(decr, decr_pred)
    Unfold(cell_pred(cl, 116))
    assert cl.val == 116