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)
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)
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)
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
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))
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
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