def client_fork(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)) Ensures(getOld(t, arg(0).val) == 12) Ensures(WaitLevel() < Level(t)) #:: ExpectedOutput(postcondition.violated:insufficient.permission) Ensures(Acc(MayStart(t))) cell.val = 12 t.start(decr, Cell.incr)
def client_fork(t: Thread, l: BaseLock) -> None: Requires(Acc(MayStart(t))) Requires(getMethod(t) == noop) Requires(l is getArg(t, 0)) Ensures(WaitLevel() < Level(t)) #:: ExpectedOutput(invalid.program:invalid.thread.start) t.start(noop)
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 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)
def client_fork_wrong_old_2(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(getOld(t, arg(0).val) == 14) cell.val = 12 t.start(decr, Cell.incr)
def client_create(b: bool) -> Thread: Ensures(MayStart(Result())) Ensures(Implies(b, getArg(Result(), 1) is 3)) Ensures(Implies(not b, getArg(Result(), 1) is 6)) Ensures(Implies(not b, getMethod(Result()) == decr)) #:: ExpectedOutput(postcondition.violated:assertion.false) Ensures(getArg(Result(), 2) is None) cl = Cell() if b: t = Thread(None, target=cl.incr, args=(3, )) else: t = Thread(target=decr, group=None, args=(cl, 6)) return t
def client_fork_precond_not_fulfilled(t: Thread, b: bool, cell: Cell) -> None: Requires(Acc(MayStart(t))) Requires(getMethod(t) == Cell.incr) Requires(cell is getArg(t, 0)) #:: ExpectedOutput(thread.start.failed:insufficient.permission) t.start(decr, Cell.incr)
def client_fork_method_unknown(t: Thread, b: bool, cell: Cell) -> None: Requires(Acc(MayStart(t))) Requires(Acc(cell.val)) Requires(cell is getArg(t, 0)) #:: ExpectedOutput(thread.start.failed:method.not.listed) t.start(decr, Cell.incr)