Write a program using the fork() system call to do the following. The parent process (main program) forks a process (CHILD 1) to compute and print the sum of first n integers where n is a variable shared between the parent and CHILD 1. It also forks another process (CHILD 2) that finds the sum of squares of the first n numbers where n is a variable it shares with the parent. Let CHILD 1 print “The sum of the first ** integers is: ****”. Let CHILD 2 print “The sum of the square of the first ** integers is: ****”. Have the parent invoke the wait () call to wait for both the child processes to complete before exiting the program. Run and show the output of the program for n=5 and n=10
Write a program using the fork() system call to do the following. The
parent process (main program) forks a process (CHILD 1) to compute and print the sum of first n
integers where n is a variable shared between the parent and CHILD 1. It also forks another
process (CHILD 2) that finds the sum of squares of the first n numbers where n is a variable it
shares with the parent. Let CHILD 1 print “The sum of the first ** integers is: ****”.
Let CHILD 2 print “The sum of the square of the first ** integers is: ****”. Have the parent
invoke the wait () call to wait for both the child processes to complete before exiting the
program. Run and show the output of the program for n=5 and n=10.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images