Laboratory Exercise on Signals and Timers
Goals: This lab exercsie provides experience with system timers and
signals.
Credit: The lab is based on Lab Exercise 6.1 in Operating
Systems, Third Edition by Gary Nutt, Addison-Wesley/Pearson Education,
2004.
Basic Problem: Determine the time required to perform a quicksort
of 10000, 20000, 40000, 80000, and 160000 items in both a single-process
context and in a multiple-process context.
Some Problem Specifics:
Guidelines for each program:
-
Each collection of timings should use three timers:
-
ITIMER_REAL is used to determine overall elapsed time,
-
ITIMER_VIRTUAL is used to determine time for the specific process, and
-
ITIMER_PROF is used to determine time for the specific process plus time of
the OS related to this process.
-
The quicksort should be performed on an array of random data.
Required Programs:
-
As a base line, a first program should set the three timers indicated
above, perform a quicksort, and retrieve processing times in a
single-process environment. This program should not include any
fork or signal calls. Also, timing should not include the time required to
initialize the array.
This first program may perform the timing, quicksort, and printout for
a single array size, with the program rerun for each of the array sizes
given above. Alternatively, the program may call the timing, quicksort,
and printout steps within a loop to handle all array sizes with a single
execution of the program.
-
Modify the program ~walker/213/c-examples/signal-1.c, so that a parent
process the amount of time required for each quicksort that is
performed in a child process. As with the base line program, timing
should not include the time required to initialize arrays.
-
Extend the second program to obtain a program that spawns two processes,
each of which sets a timer, performs a quicksort, and prints its own
processing times. In this third program, each child will do its own
processing and timing. The parent process only monitors the other
activities. If you wish, you may use Nutt's program outline from lab
exercise 6.1 as a base.
Resources:
- Program ~walker/213/c-examples/signal-1.c,
as discussed in class, illustrates the use of system timers and signals.
-
In Lab Exercise 6.1, Nutt provides general background on timers and
outlines a framework for the use of signals and timers in programs.
Work to be turned in:
-
Three programs, as described above.
-
For each program, use the script command to list the program and to execute
one or more test runs for the required array sizes.
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/213.fa04/lab-signals.shtml