コード例 #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)
コード例 #2
0
ファイル: test_thread_fork.py プロジェクト: zeta1999/nagini
def client_fork_wrong_mayjoin(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:assertion.false)
    Ensures(Joinable(t))
    t.start(decr, Cell.incr)
コード例 #3
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)
コード例 #4
0
def thread_join_no_post_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(Joinable(t))
    Requires(WaitLevel() < Level(t))
    t.join(Cell.incr, decr)
    #:: ExpectedOutput(assert.failed:insufficient.permission)
    assert cl.val == 116
コード例 #5
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))
コード例 #6
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
コード例 #7
0
def thread_join_minimal(t: Thread, cl: Cell) -> None:
    Requires(Joinable(t))
    Requires(WaitLevel() < Level(t))
    t.join(Cell.incr, decr)
    #:: ExpectedOutput(assert.failed:insufficient.permission)
    assert cl.val == 116