aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-06-16 18:40:55 +0200
committerMattias Andrée <maandree@operamail.com>2014-06-16 18:40:55 +0200
commit3465addf386e153410644616b45ed870a4098a3d (patch)
treeb45c8a2931a85467a0b1e416cee7140c4db57260
parentinfo: m + rendezvous (diff)
downloadcmdipc-3465addf386e153410644616b45ed870a4098a3d.tar.gz
cmdipc-3465addf386e153410644616b45ed870a4098a3d.tar.bz2
cmdipc-3465addf386e153410644616b45ed870a4098a3d.tar.xz
algorithms
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--info/cmdipc.texinfo128
1 files changed, 128 insertions, 0 deletions
diff --git a/info/cmdipc.texinfo b/info/cmdipc.texinfo
index 73f03ee..0d2271b 100644
--- a/info/cmdipc.texinfo
+++ b/info/cmdipc.texinfo
@@ -412,6 +412,20 @@ To enter a guarded state with a mutex,
use the verb @option{enter}. Then leave
it with @option{leave}.
+@*
+@cartouche
+@example
+create:
+ s := S(1)
+
+enter:
+ P(s)
+
+leave:
+ V(s)
+@end example
+@end cartouche
+
@node Conditions
@@ -462,6 +476,34 @@ command line arguments) perform a
@option{broadcast} if there are any
waiting peers, and otherwise @option{wait}.
+@*
+@cartouche
+@example
+create:
+ (s, c, q) := (S(1), S(0), S(0))
+
+enter:
+ P(s)
+
+leave:
+ V(s)
+
+wait:
+ V(s), V(c), P(q), P(c), P(s)
+
+notify:
+ V(q)
+
+broadcast:
+ c.value times:
+ V(q)
+
+notify all:
+ max(c.value, 1) times:
+ V(q)
+@end example
+@end cartouche
+
@node Barriers
@@ -499,6 +541,33 @@ no NUL or slash, between 1 character and
254 characters long, and prefixed with a
slash.
+@*
+@cartouche
+@example
+[sysv] create:
+ (s, m) := (S(threshold), S(1))
+
+[sysv] enter:
+ P(s), Z(s)
+ if P(m, nonblocking) does not fail:
+ if s.value = 0:
+ s.value := threshold
+ V(m)
+
+[posix] create:
+ (x, c, q) := (S(1), S(0), S(0))
+
+[posix] enter:
+ P(x), V(c)
+ if c.value = threshold:
+ V(q, delta = threshold - 1)
+ c.value := 0
+ V(x)
+ else:
+ V(x), P(q)
+@end example
+@end cartouche
+
@node Shared Locks
@@ -553,8 +622,34 @@ Release shared locking.
@item exclusive unlock
Release exclusive locking.
+@*
@end table
+@cartouche
+@example
+create:
+ (x, s, m) := (S(1), S(0), S(1))
+
+shared lock:
+ P(m)
+ if s.value = 0:
+ P(x)
+ V(s), V(m)
+
+exclusive lock:
+ P(x)
+
+shared unlock:
+ P(m), P(s)
+ if s.value = 0:
+ V(x)
+ V(m)
+
+exclusive unlock:
+ V(x)
+@end example
+@end cartouche
+
@node Rendezvous
@@ -583,6 +678,39 @@ no NUL or slash, between 1 character and
254 characters long, and prefixed with a
slash.
+@*
+@cartouche
+@example
+[sysv] create:
+ (m, i, q) := (S(1), S(0), M())
+
+[sysv] enter:
+ P(m)
+ if i.value = 0:
+ V(i), V(m)
+ send(q, type = 1)
+ receive(q, type = 2)
+ else:
+ P(i), V(m)
+ receive(q, type = 1)
+ send(q, type = 2)
+
+[posix] create:
+ (m, i, p, q) := (S(1), S(0), S(0), M())
+
+[posix] enter:
+ P(m)
+ if i.value = 0:
+ V(i), V(m)
+ send(q), P(p)
+ receive(q)
+ else:
+ P(i), V(m)
+ receive(q), V(p)
+ send(q)
+@end example
+@end cartouche
+
@node GNU Free Documentation License