Homework Fork
Homework Fork
1. What will be the output of the program? Interpret the output and explain what each
child process does.
2. Run the program multiple times. You will see the output changes from time to time.
What is the reason? Explain.
3. Why does each child process increment values in a specific part of the array? How is
this part determined?
4. Why the parent process’ array does not change?
5. How does the parent process wait for all child processes to finish? Which system call
is used for this operation?
6. What does the parent process do while waiting for child processes to finish? Which
code block is executed during waiting?
7. Which system calls and functions are used in this program? Explain the purpose of
each.
Change the given program so that the parent process defines the integer array as a shared
memory area and the child processes attach to this memory area and performs increments
on this shared array. After the child processes complete, the parent process will print 1 2 3
4 5 6 7 8 9 10 to the screen as the output. Explain the program logis and the system calls
you make in this new program.
Note: You will not be graded with this homework, but you will be responsible at midterm
and final exams.