%3Cp%3E%3Cspan%20class%3D%22c1%22%3EWrite%20a%20C%20program%20that%20will%20acce
ID: 3552834 • Letter: #
Question
%3Cp%3E%3Cspan%20class%3D%22c1%22%3EWrite%20a%20C%20program%20that%20will%20accept%20the%20names%20of%0A3%20processes%20as%20command-line%20arguments.%20Each%20of%20these%20processes%20will%0Arun%20for%20as%20many%20seconds%20as%3A%20(PID%2510)*2%2B3%20and%20terminate.%20The%20parent%0Aprocess%20will%20reschedule%20each%20child%204%20times%20before%20giving%20up.%20When%0Aall%20children%20have%20been%20scheduled%204%20times%2C%20the%20parent%20will%0Aterminate.%20Please%20use%20UNIX%20System%20calls.%3Cbr%20%2F%3E%3C%2Fspan%3E%3C%2Fp%3E%0AExplanation / Answer
int main() { int i,j,k,l; printf("hello before fork "); printf("i : %d ",i); i=fork(); printf(" "); if(i==0) { printf("Child has started "); printf("child printing first time "); printf("getpid : %d getppid : %d ",getpid(),getppid()); sleep(5); printf(" child printing second time "); printf("getpid : %d getppid : %d ",getpid(),getppid()); j=fork(); printf("Child has started "); printf("child printing second time "); k=fork(); printf("Child has started "); printf("child printing third time ");l=fork(); printf("Child has started "); printf("child printing fourth time "); } else { printf("parent has started "); printf("getpid : %d getppid : %d ",getpid(),getppid()); printf(" "); } printf("Hi after fork i : %d ",i); return 0; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.