search
Log In
1 vote
717 views

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?

in Operating System
edited by
717 views
0

$S_3$ and $S_2$ are concurrent processes since fork() system call was called at that level but you have shown dependency between them.. you can check here @11:00 something 

1 Answer

1 vote

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

shouldn't S3 and S4 be executing in parallel?

and after S3 is finished S2 will execute

as S2 comes after S3

Fork L1;         L1: S3; S2;        goto L3; 

0
No.

After S1 there is fork system call , with label L1 .and L1 is given S2,S3 . so , after S1 2 concurrent (parallel ) processes S2,S3 will be there . after that S4 comes .
0
L1 is S3; S2

not S2; S3

So S3 should be executed before S2?
1

I've seen the vide @ankitgupta.1729 mentioned

As per your answer S2 and S3 is getting executed in parallel. But in question its mentioned L1: S3; S2

so a new process should be created that executes S3 then S2

0

Yes u r right  . plz u see this video  30:00 . its the same question. 

0
count should be 4. I think framing question might be wrong

Related questions

9 votes
6 answers
1
3.6k views
Below is the precedence graph for a set of tasks to be executed on a parallel processing system $S$. What is the efficiency of this precedence graph on $S$ if each of the tasks $T1, \dots , T8$ takes the same time and the system $S$ has five processors? 25% 40% 50% 90%
asked Jun 21, 2016 in Operating System jothee 3.6k views
8 votes
2 answers
2
1.3k views
Draw the precedence graph for the concurrent program given below S1 parbegin begin S2:S4 end; begin S3; parbegin S5; begin S6:S8 end parend end; S7 parend; S9
asked Sep 13, 2014 in Operating System Kathleen 1.3k views
2 votes
1 answer
3
...