Professional Documents
Culture Documents
Department of Computing
COMP3101
Tutorial 3 Questions
This tutorial will require you to write C code. You can use the C code from the last lecture to assist you.
QUESTION 1
Write a C program where a parent process will create two children processes. The first child will sum
the positive whole numbers less than 20 while sleeping between each calculation. The second child
process will perform a similar operation, but will sum the positive whole numbers less than 5 and will
not sleep between each calculation. The parent process should only wait on the second process to
complete then will exit.
You should use the waitpid() system call to accomplish this. The definition of waitpid() is shown
below:
QUESTION 2
Write a C program where a parent process will create one child process. The parent process will then
access the virtual /proc directory, and print the resource limits associated with this process.
A description and location of the the limits file is shown below. You can use the system() system call to
use the command line to accomplish this task. Remember that the cat() function can be used to print the
contents of files.