CS571 Fall 2010
Programming Assignment #1
This is a multi-part assignment.
NOTE: When an assignment says "Write a program in C that (whatever)",
you must provide:
the source code,
compile instructions,
relevant comments within the code,
listing and explanation of the output.
Student programming projects must adhere to the CS
Honor
Code.
Part 1: Verifying your programming
environment:
An exercise about process creation in UNIX/Linux
In this exercise, you will run and study a simple program that creates
multiple processes in UNIX or Linux.
Do the following:
Copy the program multiple-forks.c
and save it under the name multiple-forks.c
Examine the program's source code and describe how it should
behave when executed.
(Note: getpid() is a simple system call that returns the
process identifier of the process that invokes it.)
Compile the program:
gcc multiple-forks.c -o multiple-forks
Run the program:
./multiple-forks
Observe the output and re-examine the source code.
Answer the following questions:
How many processes were created during the execution of this
program?
What is the hierarchy among these processes?
In what order did the processes start and complete? Why?
Part 2: Observing the OS as it runs
the program
In this exercise you will use OS tools to observe the actions of the
program.
Do the following:
Modify the program so that it takes several minutes to execute
There are several ways to do this...iterate more times, or
briefly pause execution between iterations
In another terminal on the same system:
Identify the processes associated with the program
What information do the following tools reveal about the
program?