Question: Please answer all parts and explain. Thanks! Exercise #1 [20 pts] Consider the following C program (assume that there are no compilation or execution errors

Please answer all parts and explain. Thanks!

Please answer all parts and explain. Thanks! Exercise #1 [20 pts] Consider

the following C program (assume that there are no compilation or execution

Exercise #1 [20 pts] Consider the following C program (assume that there are no compilation or execution errors of any kind): #include 2 | #include unistd.h> 3 | #include 4 5 int main (int argc, char xkargv) int count if ((argc !;: 2) 11 (sscanf(argv [1],"%d",&count) !-1)) { 9 10 argv [0]); ", fprintf(stderr,"Usage: exit (1); %s 12 13 14 15 16 17 18 19 20 21 pid t pid1, pid2; while (count0) pid! = fork(); if (pid1 >0) f pid2 fork); count count - 2; else if (pidl -0) count -count-1; 23 24 25 exit(0); Question #1 [2 pts] If the command-line argument passed to this program is 0, this program creates no child process. How many child processes does this program create if the command-line argument is 1? Question #2 [3 pts] How many child processes does this program create if the command-line argument is 2? Question #3 [12 pts] Let T(n) be the number of processes this program creates when its input is n (the answer to Question #1 above is thus T(1) Write an recursive formula (i.e., a recurrence relation) that gives T) as a function of one or more values of T for smaller input (i.e, smaller . Explain your reasoning. Feel free to double-check your formula by actually running the program and possibly augmenting it so that it allows you to count processes in whichever way you want. Question #4 [3 pts] Say the maximum number of processes that can be created on your machine is 100,000 (you can find out the actual number of your machine with ulimit -u What is the smallest value of the command-line argument for which the above program would experience failed fork() calls

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!