Question
Compile the following program( using online terminal , colcalc ) as lab3.c. Run the lab3 and observe the number of statements printed to the terminal.
Compile the following program(using online terminal , colcalc) as lab3.c. Run the lab3 and observe the number of statements printed to the terminal. The fork() call creates a child that is a copy of the parent process. Because the child is a copy, both it and its parent process begin from just after the fork(). All of the statements after a call to fork() are executed by both the parent and child processes. However, both processes are now separate and changes in one do not affect the other.
#include
main()
{
fork();
fork();
printf("Process ID is: %d ", getpid());
printf("Parent Process ID is %d ", getppid());
sleep(2);
}
Show the output as a screenshot. Write the output of your program and draw a process tree and label the processes with their process IDs.
Solve this in less than an hour an you will be granted an upvote, that's a promise !
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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