Main
Lab 9
Signals and processes
- Unix signals
- Handling signals in Bash: http://www.linuxjournal.com/article/10815
- C/C++ signals tutorial
- Mini core war
New processes and Synchronization
Write a main
function with an int
array of size 10. Fill the array with random values. Print the sum of the values.
Then use fork
to create a child process. Refer to this week's lecture note for examples of how to create a child processes using fork
. Here's the link:
https://ix.cs.uoregon.edu/~norris/cis330/lecture23.pdf
- In child process add the elements 0-4 from array and save the result in a fie
out.txt
- In the parent process add the elements 5-9 from array. Wait for the child process to finish writing and closing the
out.txt
file. Then open the file in parent process and get the total value of elements 0-4. Using this number print the sum of the values of the whole array (elements 0-9).