in Programming
599 views
0 votes
0 votes
if (e1 || e2 )
{
    print "OK"
}
print "HAI"

if e1 is true, with out checking e2 ===> it directly prints OK then HAI

let take, it is fork in the place of e1 ===> 1) parent ( which have >  0 )  ===> e1 is true,  ===> OK HAI printed

                                                                        2)  child ( which have = 0 ) ==> e1 false, ==> check e2.

 

is it right or wrong?
in Programming
599 views

4 Comments

refer the original question mam, it should be right.
0
0

check it

This way  if (fork()&&fork()){fork();} works :

P1 --              Parent   .. 1st process is P1 

/    \               // executed first fork() from if() condition  

P2  C1     --           ..      C2 is 2 nd process 

/  \                //    here second fork() executed from if() condition 

P3   C2       ---        ...    C3  is 3rd process

/  \               //  now we are  inside body of condition , third fork() is executed 

P4  C3       ---        ...      C4 is 4 th process

https://gateoverflow.in/137613/%23threads 

right?

0
0
it is right mam
0
0

Please log in or register to answer this question.