diff --git a/Concurrent Systems/notes/3.md b/Concurrent Systems/notes/3.md index 34e568d..4f0d343 100644 --- a/Concurrent Systems/notes/3.md +++ b/Concurrent Systems/notes/3.md @@ -25,4 +25,23 @@ X.test&set() := ###### How do we use it? ``` -lock() \ No newline at end of file +lock() := + wait X.test&set() = 0 + return + + +unlock() := + X <- 0 + return +``` + + +#### Swap +``` +X general register + +X.swap(v) := + tmp <- X + X <- v + return tmp + \ No newline at end of file