Understand the fork() regarding its returning values, global/local variables dec
ID: 3714220 • Letter: U
Question
Understand the fork() regarding its returning values, global/local variables declared in the parent's process, and processing
Attached is a lab.c file containing a fork() statement. Compile and run it. Questions below
-Lab.c
Questions:
1) When fork() is executed, what is happening to the returning values in parent and in child?
2) After fork() is executed, how many more process is created? What is the PID?
3) Why the values of var_global and var_local are different in parent and child processes respectively?
Explanation / Answer
1. when fork() is executed, the returning values in parent is 10 and 20,
in child the values are incremented.
2. two processes are created and pid's are 12803 and 12804
3. because the parent process will be executed more times than the child process.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.