Saturday 15 August 2015

c - How many processes does this program create, including the initial parent process? -


I am trying to figure out how many processes are created from this program, including initial basic process The correct answer should be 9, but I do not understand why answer 9 is why. How are these 9 processes done? thank you in advanced!

  #include & lt; Stdio.h & gt; # Include & lt; Unistd.h & gt; One ?? | Int main () {pid_t John; John = Fork (); If (John == 0) {fork (); Fork( ); Fork( ); } / * Consumption of resources of any other process * / / * It does not make a new process * / Consumption (); consume( ); Return 0; }    

  John = fork (); // a new process fork, if we now have 2 (John == 0) {// hair process goes to the statement fork (); // Fork Process Fork (2) Fork Process; // Processes fork is continuing, so we have 2 more fork (); // 4 processes continue fork, so we have 4 more more} // To do this here, first, the child processing of the fork is now 8 process / / is adding the first parental process, which is 9 total.    

No comments:

Post a Comment