Question: PLEASE ONLY DO QUESTION E AND F!!!!!!!!!!!!! C PROGRAMMING system calls 1. Process Creation in Linux: Run the code below in your shell and answer

PLEASE ONLY DO QUESTION E AND F!!!!!!!!!!!!! C PROGRAMMING

PLEASE ONLY DO QUESTION E AND F!!!!!!!!!!!!! C PROGRAMMING system calls 1.

system calls

1. Process Creation in Linux: Run the code below in your shell and answer the questions that follow: #include #include #include int main(int argc, char **argv, char **envp) { printf("%d * ", getpid()); fork(); printf("%d ** ", getpid()); fork(); printf("%d *** ", getpid()); sleep(20); return EXIT_SUCCESS; } a. How many processes are created (including the program itself)? b. Add a third fork () right after the ones in the program. How many processes are there? C. What is the relation between the number of consecutive fork calls and total number of processes created? d. Use shell command pstree to capture the relations between the different processes of parts a and b. (hint: run 2 shells: on the first shell use the command ps to get your shell process PID, then run the code. On the other shell, run pstree -p of the first shell you run your code on). @ubuntu: Lab_65$ pstree -p 3507 bash (3507) P1(5502) P1(5503) T-P1(5506)P1(5509) -P1 (5507) -P1(5504) P1(5508) -P1(5505) -P1(5510) TP1(5511) P1(5514)P1(5517) LP1(5515) -P1(5512)21(5516) -P1(5513) -pstree(5519) Run the code after modifying it as follows: o Comment sleep (10) Add two more fork() calls (a total of 5 times) e. Run the code multiple time. Why does the parent of some processes change (sometimes init process (PID=1) and sometimes the CLI)? f. Modify your code to make sure that a parent process will not terminate before any of its children

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!