Question: Write a C program (procs.c) that creates three processes: a parent process that creates two child processes. The first child should do the following: -
Write a C program ("procs.c") that creates three processes: a parent process that creates two child processes.
The first child should do the following:
- display "First child is born, my pid is ..."
- display 100 times the message "First child executes iteration X", where X is the number of the iteration - display "First child dies quietly."
The second child should do the following:
- display "Second child is born, my pid is ..."
- display 100 times the message "Second child executes iteration X", where X is the number of the iteration
- display "Second child dies quietly."
The parent process should do the following:
- display "Parent process is born, my pid is ..."
- create the first child
- create the second child
- wait for both children to complete their execution
- display "Parent process dies quietly."
Compile the program using gcc and name the executable "procs.out". Execute the program several times and notice how the output of the two children interlace. Files "procs.c" and "procs.out" should be posted under the Homework 2 assignment for grading.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
