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

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!