Created
August 15, 2023 20:29
-
-
Save hwayne/3cf0d509bdbd12a0bce298277ea40561 to your computer and use it in GitHub Desktop.
Demonstration of bug in distributed lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONSTANTS | |
Threads = {t1, t2, t3} | |
NULL = NULL | |
SPECIFICATION Spec | |
PROPERTY NoRaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- MODULE distlock ---- | |
EXTENDS TLC, Integers, Sequences | |
CONSTANT Threads, NULL | |
Range(f) == {f[x] : x \in DOMAIN f} | |
(*--algorithm distlock | |
variable | |
data = 0; | |
lock = NULL; | |
process writeData \in Threads | |
variable tmp = -1; | |
begin | |
GetLock: | |
await lock = NULL; | |
lock := self; | |
readData: | |
tmp := data; | |
calcData: | |
tmp := tmp + 1; | |
writeData: | |
data := tmp; | |
ReleaseLock: | |
lock := NULL; | |
end process; | |
process clock = "clock" | |
begin | |
ExpireLock: | |
lock := NULL; | |
end process; | |
end algorithm; *) | |
==== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment