CMPS 105: Systems Programming

Programming Assignment #1: A Timer Program


Remember: your programming assignment must be turned in online.

The Basics

The goal of this assignment is to get everyone up to speed on system programming, to use man, to get familiar with system types, and to gain some familiarity with the system call interface. A secondary goal is to use some of the programming tools provided in the Unix environment.

In this assignment, you are to implement a timer program that times other programs. It will be called like this:

mytime foo a b c

where "foo" is the name of a program and "a b c" are the parameters to foo.


The Details

To implement your program, you will need to use two system calls, gettimeofday() and system().

gettimeofday() returns the current time.

system() takes a string containing a command and executes that command.

Your program should calculate the amount of time it takes for the called program (foo in the example above) to run.

Once you have your program running, time three programs: du, ls, and ps (read the man pages for these programs if you are unfamiliar with them). Record the times and report them in a separate document called Output. In that document, speculate on the reasons for the differences in the times that the three programs take to execute.

Note: You must check and correctly handle all return values. This means that you need to read the man pages for each function to figure out what the possible return values are, what errors they indicate, and what you must do when you get that error.


What to turn in

Your code, a working makefile, your design document, and your output file. In addition, include a README file to explain anything unusual to the TA — testing procedures, etc.

REMEMBER: Do not submit object files, assembler files, or executables. Every file in the submit directory that could be generated automatically by the compiler or assembler will result in a deduction from your programming assignment grade.


sbrandt@cse.ucsc.edu