GATE / CS ARCHIVE

GATE CSE 1998 / QUESTION 24(b)

Fork-join precedence program

Operating Systems · Synchronization & Concurrency · Full GATE CSE 1998 paper

GATE 1998, Q24(b) Descriptive
Report issue

Synchronization & Concurrency

Question 24(b), GATE 1998: Represent the graph with edges S1→S2,S1→S3,S1→S4,S1→S5,S2→S4,S4→S5,S3→S5 using parbegin/parend.
Question 24(b), GATE 1998: Represent the graph with edges S1→S2,S1→S3,S1→S4,S1→S5,S2→S4,S4→S5,S3→S5 using parbegin/parend.
Tap to enlarge
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;
end

Here 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.

Original paper, page 8