GATE / CS ARCHIVE

GATE CSE 1992 / QUESTION 12(a)

Precedence graph for nested parallel blocks

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

GATE 1992, Q12(a) Descriptive
Report issue

Synchronization & Concurrency

Question 12(a), GATE 1992: Draw the precedence graph for this concurrent program. Within begin/end statements are sequential; parbegin/parend runs its components concurrently and joins them:
S1;
parbegin
  begin S2; S4 end;
  begin S3; parbegin S5; begin S6; S8 end parend end;
  S7
parend;
S9
Tap to enlarge
Answer & solution

Answer: Edges: 1→2,3,7; 2→4; 3→5,6; 6→8; 4,5,8,7→9. (no official key was published)

S1 executes before the outer fork. Its three branches start with S2, S3, and S7. In the first branch S2 precedes S4. In the second branch S3 precedes a nested fork: S5 runs in parallel with the sequential pair S6 then S8. The outer join waits for S4, both S5 and S8, and S7 before permitting S9.

The precedence graph (arrows are immediate dependencies) is:

          ┌→ S2 → S4 ─────────┐
          │                  │
S1 ───────┼→ S3 ─┬→ S5 ─────┼→ S9
          │      └→ S6 → S8 ─┤
          └→ S7 ─────────────┘

Its exact edge set is {(S1,S2),(S1,S3),(S1,S7),(S2,S4),(S3,S5),(S3,S6),(S6,S8),(S4,S9),(S5,S9),(S8,S9),(S7,S9)}. This is a transitive reduction: edges such as S1→S9 are implied and need not be drawn. It uses only statement vertices; explicit fork/join vertices would be an equivalent representation.

Do not add S4→S3, S5→S6, or S8→S7: textual order among separate parallel branches does not force execution order. Conversely, S9 must not start after just one branch finishes. The structure imposes control dependencies only; no extra read/write data dependencies are supplied.

Original paper, page 8