Question: Write a C program that creates a child process. Both the parent process and child process should be able to identify itself and print out

 Write a C program that creates a child process. Both the

Write a C program that creates a child process. Both the parent process and child process should be able to identify itself and print out "parent" for the parent process and "child" for the child process. Additionally, initiate a global counter with 0 and allow each process to increment the counter. Run the loop for 20 iterations. In each iteration, a process prints out the counter value. The following is a sample output (please note, you may get a different output): The parent process counter is 30 The child process counter is 1 The parent process counter is 31 The child process counter is 2 The parent process counter is 32 The child process counter is 3 The parent process counter is 33 The child process counter is 4 The parent process counter is 34 The child process counter is 5 The parent process counter is 35 The child process counter is 6 The parent process counter is 36 The child process counter is 7 The parent process counter is 37 Why output from each process is not consecutive? [12M] Well documented and working code [7M], explaining the behaviour of the code [5M]

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!