Menu
support@nursinghomework.org
+1 714-215-3097

(Solved) : Write Unix Linux Program Demonstrate Use Fork Wait System Calls Program Perform Exactly 15 Q35562927

Write a Unix/Linux program to demonstrate theuse of fork() and wait() system calls.

– The program should perform exactly 15 iterations beforeterminating.

– In each iteration, the program will create 10 child processes(p0 to p9).

– Each child process will print its decimal digit (0, 1, …, 9)once without newline before exiting.

– After creating the 10 children in each iteration, the parent(original process) will wait until all its 10 children havecompleted, then it will print a new line before going to the nextiteration or exiting.

– The output of this program, when properly implemented, willillustrate the unpredictable order in which the processes arescheduled to run.

– Use a loop with only one instance of the fork() call in yourprogram.

– In order to wait for all the children to complete, usewait(NULL) in a loop until the return value of wait(NULL) is-1.

Output should be similar to what is below:

9 8 5 6 7 2 4 3 1 0

8 1 4 9 7 6 5 3 2 0

2 7 8 9 6 5 4 3 1 0

0 1 3 9 8 7 4 2 6 5

8 7 6 5 3 2 0 1 4 9

2 1 4 5 3 6 7 8 0 9

0 1 2 3 4 5 6 7 9 8

0 1 2 4 3 5 6 7 8 9

0 1 2 3 5 4 6 7 8 9

9 8 5 4 3 2 0 7 6 1

0 1 2 3 6 7 8 5 9 4

0 1 4 2 6 8 5 3 7 9

0 1 2 3 4 5 6 7 8 9

6 7 9 5 4 3 8 2 1 0

2 3 9 4 5 6 7 0 8 1

Leave a Reply

Your email address will not be published. Required fields are marked *