Description of exercise:
First, study the code in Figure 5.5 on textbook. The parent thread creates
the child thread to complete the summation and the parent writes the result
out. In this exercise, you are asked to simulate such behaviour with processes.
- You should use fork() to create the child process.
- Parent should pass the parameter to the child AFTER the fork().
Of course, such data passing is done by shared memory.
However, parent must also notify the child that such parameter
passing is completed. So parent must send child a signal and
child must catch such signal.
- After child has got the parameter and completed the calculations,
it also transfers the sum to parent. The scenario is similar.
Child will send parent a signal and parent must catch it.
- Finally, parent print the sum out.
- A process can send a signal to another one by kill(). Try to read
the man page of kill. (Try "man -s 2 kill")