Page 41 -
P. 41
28 N. Russell and A. ter Hofstede
add milk add milk
AND serve tea XOR serve tea
join join
add sugar add lemon
(a) (b)
add milk
OR serve tea add sugarcube Thread serve tea
join join
add sugar
(c) (d)
Fig. 2.3 Synchronization constructs
The XOR-join (or the eXclusive OR-join), which merges the thread of control
from one of the several incoming branches into an outgoing branch.
The OR-join, which synchronizes the various execution threads in those incom-
ing branches that are currently active and merges them into a single execution
thread in an outgoing branch.
The Thread-join, which synchronizes and merges multiple concurrent execution
threads in the same branch into a single execution thread.
This distinction between each of these operators is illustrated in Fig. 2.3a–d, which
continues the previous example. Figure 2.3a shows an AND-join, which only allows
the serve tea task to commence once both the add milk and add sugar tasks have
been completed. In contrast, in Fig. 2.3b, based on an XOR-join, once one of the
add milk or add lemon tasks has completed, the serve tea task can be initiated.
Figure 2.3c utilizes an OR-join and allows the serve tea task to commence once
all of the preceding add milk and add sugar tasks that have been initiated have
completed. Finally, Fig. 2.3d illustrates the Thread-join construct where multiple
concurrent instances of the add sugarcube task must complete and the associated
threads of control must be synchronized and merged into a single thread before the
serve tea task can commence.
AND-Join Variants
Although the behavior of each of these join constructs appears to be well defined
and predictable, upon closer examination it becomes clear that there are a variety of
ways in which they can be actually implemented. If we look at the AND-join, for