edited by
3,832 views
2 votes
2 votes

Consider the code fragment: 

count = 3;
S1;
Fork L1;         L1: S3; S2;        goto L3;
S4;
Fork L2;         L2: S6;              goto L3;
S5;                 
L3: join count
S7 

Which one of the following represents correct precedence graph of the above code fragment?
the answer is given

but I’m getting

where am I wrong?

edited by

2 Answers

1 votes
1 votes

Answer should be this graph :Lightbox

count = 3; 
S1; 
Fork L1;         L1: S3;        goto L3;   // Create child process (S2,S3) If there is a Label with fork ,

                                                  means both are ( S2 and S3 )concurrent process .

                                                  S2 continue with this but S3 with Label L1

S2;                                    //   no fork :- their is no concurrency between S2 , S4 . so, S2 continue with S4

S4; 

Fork L2;         L2: S6;              goto L3 ;        // their is concurrency between S5, S6 . 

S5;         

         
L3: join count 


S7  

 

Join   count

        count=count-1

        if count!=0 , then

             Quit

0 votes
0 votes

option 1 can never be the answer. I mean how???

First thing to note is s3 and s2 needs to be executed sequentially.But most of the answers given makes concurrent execution which is wrong.

Second thing is lets assume that s3 and s2 can be executed concurrently then after execution they directly will jump to L3 without executing the below code from line 3-5 is never possible.

So 2 option should be right.

Related questions

10 votes
10 votes
2 answers
1
Kathleen asked Sep 13, 2014
3,475 views
Draw the precedence graph for the concurrent program given belowS1 parbegin begin S2:S4 end; begin S3; parbegin S5; begin S6:S8 end parend end; S7 parend; S9
0 votes
0 votes
0 answers
2
3 votes
3 votes
1 answer
3
1 votes
1 votes
2 answers
4
♥_Less asked Jan 12, 2018
1,749 views
What is the number of child process created ?Answer given was 63, BUT i am getting 9 !