Fork-join precedence program
Synchronization & Concurrency


Answer & solution
Answer: S1; parbegin {S2;S4} || {S3} parend; S5. (no official key was published)
S1 must finish first. Afterward S3 can run independently of the chain S2 then S4. S5 must wait for both branches. A structured program is:
begin
S1;
parbegin
begin
S2;
S4;
end
S3;
parend;
S5;
endHere parbegin starts its two child statements concurrently, and parend joins them. The first child is a sequential block, so S2 precedes S4. The second child is S3. The final join guarantees both S3 and S4 finish before S5. Edges S1→S4 and S1→S5 are already implied by the paths through S2/S4, but are still satisfied. There is no imposed order between S3 and S2 or between S3 and S4, so the program preserves the graph's available parallelism rather than unnecessarily serializing it.


