Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I. Compile and execute the following programming exercises: Figure 3 . 3 0 : Program shows that value modification by child doesn't affect value for
I. Compile and execute the following programming exercises:
Figure : Program shows that value modification by child doesn't affect value for parent process. Print the content of the global variable 'value' in child and parent.
Figure : Program shows that processes are created. Add a print statement after each fork
Figure Fig in some books : Program shows that total processes are created. Display their 'pid's.
Figure Fig in some books: Program shows that "LINE J after call to 'execlp will not be printed if execlp is successful.
Figure Fig in some books : Program shows the outputs at lines A B C and D
Figure Fig in some books: Programs show the outputs at lines X and Y
Example of adding print statements to display process id in Figure :
#include
#include
#include
int main
int i;
for i; i; i
fork;
if i printfLoop : hello from d
getpid;
if i printftLoop hello from d
getpid;
if i printfttLoop : hello from d
getpid;
return ;
II Zombie & Orphan Processes
Zombie Process
When a child process terminates, an association with its parent survives until the parent in turn either:
calls wait or
terminates normally
The child process entry in the process table is therefore not freed up immediately. Although no longer active, the child process is still in the system because the exit code needs to be stored in case the parent subsequently calls wait The child becomes what is known as defunct, or a zombie process.
Orphan Process
If a parent process did not invoke wait and instead terminated, its child processes remain as orphan processes
Compile and execute forkc program. The original process the parent finishes before the child has printed all of its messages, so the next shell prompt appears mixed in with the output. Does the child become an orphan? Why or why not?
Convert the forkc program to a zombie process. Hint: change the number of messages. If the child prints fewer messages than the patent, child will finish first and will exist as a zombie until the parent has finished.
III. Submit the screenshots of the compilation, execution, and results.
If you get "warning: implicit declaration of function 'wait' change #include to #include
Do not submit the source codes. Points will be deducted, if instructions are not followed.
Submit all screenshots on a single file, sequentially numbered.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started