retagged by
657 views
0 votes
0 votes

how to make concurrency diagram plz explain?

retagged by

1 Answer

Best answer
4 votes
4 votes

                   FORK-JOIN STRUCTURE

 fork L;

means to create a new child process, which will start it's execution from label L. And the parent process will continue it's execution from instruction following the fork statement.

join count;

This is where processes join. The "count" tells the number of processes to be joint. Whenever a process joins, the count is decremented by 1. If the count is not zero, the process terminates. If it is zero, i.e. this is the last process, it continues to execute further instructions. This is how it works:

count = count - 1;
if(count != 0) then
    quit;

Now, coming to your question. The count is initialized to 2, so two processes will join.

At starting, single process is running, which will execute A. Then fork L creates a child process that starts it's execution from label L, and executes statement C. While the parent process(original process) continues to execute B. Both these processes join at label M. And one of these (whichever reaches last) will execute D.

This gives the following concurrency diagram:-

Option (A)

Fork-join structure is nicely explained in this lecture: https://www.youtube.com/watch?v=CN9_YXGdQV8&list=PLLDC70psjvq5hIT0kfr1sirNuees0NIbG&index=4

selected by

Related questions

3 votes
3 votes
3 answers
1
3 votes
3 votes
1 answer
3
0 votes
0 votes
2 answers
4
Pavan Shetty asked Nov 24, 2018
1,746 views
A process executes the following segment of code:int main() { fork(); fork() && fork();}The number of new processes created is __________Can someone pls explain...