Search code examples
graphmultiprocessingfork-join

Fork and Join (Graph)


How would we describe the following graph like the example (with fork and join)?

graph

In the example below why does the "count" start with 3?

example


Solution

  • How would we describe the following graph like the example (with fork and join)?

        P1;
        FORK L1;
        FORK L2;
        P2;
        FORK L4;
    L3: JOIN 2;
        P5;
        Goto L4;
        
    L1: P3;
        FORK L3;
    L2: JOIN 2;
        P4;
        P6;
    L4: JOIN 3;
        P7;
        
    

    Up to 5 tasks may concurrently execute

    why does the "count" start with 3?

    It just is a name for the constant 3 that is later used for a JOIN. It denotes the number of threads that need to arrive at that JOIN Count statement before the joined thread will continue with further tasks. That 3 corresponds to the number of incoming arrows at node S7 in the graph.