Concurrency Fundamentals
1 Concurrency Problems
- Mutual Exclusion
- (Asynchronous) Message Passing
- Synchronization
1.1 Concurrency Folk Theorems
- Folk Theorem: Given any one mechanism for the above, the others cannot be built
- Folk Theorem: Given any two of the above, the third can be built.
2 Elementary Constructs
- Semantics of Semicolon ;
- Semantics of Parallel Bar ||
- Semantics of Fat Bar []
2.2 <>
statements
- Angular-brackets: The enclosed statements are performed
atomically.
- Defining the semantics of "atomic" is a goal of this course.
- For now: No interleaving of other processes/ threads.
2.3 <await>
statements
<await B => S>
B is a side-effect-free Boolean expression. S is
a code segment.
- Semantics, first cut:
- {Wait until B is true. Execute S. Atomically. Once.}
- Semantics, more to come.
- An Abstract Data Type with two methods: P and V.
- Some literature uses "wait" instead of P, and "signal" instead
of V.
- Uses await-statements.
- Semaphores
2.5 Send + Recv Primitives
- In process Q:
P ! msg
to process P send message msg
- In process P:
Q ? v
from process Q receive a message and store it in v
- The send from Q and the recv by P appear as a single event to an
external observer.
- No "buffering".
- The primitives of distributed computing.
2.6 Shared Tuple Space
- A tuple is an ordered sequence of values, not necessarily of the
same type.
- Ex: ("hello", true, 0.123, 50)
- T, a shared tuple space, a bag of tuples. Collection possibly
with dupes. For now, assume just one T.
- read from a shared tuple space T: read("hello", ?bl, ?rn, ?in);
item read remains in T.
- input("hello", ?bl, ?rn, ?in); T loses the item input. Atomically.
- write into a shared tuple space T: output("there", 44); T gains the
item written. Atomically.
3 Distributed Computing Architectures