I was referring to this page which defines fork, join and precedence graph as follows:
- When the statement
Fork(label)is executed by a thread of control, a second thread of control is started from the statement with the specified label. The two threads execute concurrently.- When the statement
Join(count)is executed, where count is an integer variable, the value of count is decremented. If the resulting value is positive the executing thread is terminated.- A PRECEDENCE GRAPH is a directed, acyclic graph where nodes represent sequential activities and where arcs, say from node i to node j, require that activity i complete before activity j can start.
Base upon this I have been asked to draw precedence graph for a code containing fork and join constructs. For simple code, I can do. Also once given both code and precedence graph, I can see how the two correspond to each other. However when the code gets little bit complex, it becomes difficult to prepare precedence graph for me. Also doing reverse, from precedence graph preparing fork-join code is almost always difficult for me.
Can anyone give me intuitive stepwise procedure explaining how to obtain fork-join code from any given precedence graph?
Can we take example of following graph to apply the steps and get the fork and join code:
