The purpose of this assignment is to test your programming skills and to prepare you for future assignments. In a later assignment you will be writing a simple parallel make utility that will use multiple threads to compile programs in parallel.
Obtaining help
You are to do this assignment on your own, but you may ask me for help at any
time. The earlier you start the assignment, the more help will be available.
You may obtain help from me before or after class, by coming to my office,
or by email.
Read through the entire assignment and look at the cover sheet before writing any code. You will be graded not only on the correctness of your programs, but their clarity and the methods you used for testing. You must follow the programming style guidelines.
You should always run lint as part of the testing of your program. Unfortunately, lint is not available on the Linux systems. If you are running in the Linux Lab, open a separate window and log into you account on one of the Sun machines. You can run lint from that window.
Part 0:
Make an assign1/part0 directory and place in it just the files
from your recitation 1 that you need to compile and test the
get_modify_time function. Include the makefile but remove the
references to the programs from Chapter 5 that you are not using. The
only source programs you need are get_modify_time.c and
test_get_modify_time.c.
Test test_get_modify_time and make sure it is still working.
Part 1:
Make an assign1/part1 directory and copy the get_modify_time.c
file from Part 0 into this directory.
Write a function called compare_modify_times and place it in its own
file, compare_modify_times.c. The prototype of this function is
int compare_modify_times(char *path1, char *path2);
This function compares the modification dates of the two given files
and returns either 0 or 1 as follows:
Write a main program called test_compare_modify_times that takes two command line parameters, calls compare_modify_times with these parameters and reports the result.
Test you programs as completely as possible.
Part 2:
Make an assign1/part2 directory and copy the
get_modify_time.c, compare_modify_times.c
and makefile from Part 1 into this directory.
Write a function called check_older with prototype:
int check_older(char *path, char **paths):
The paths is a NULL-terminated array of paths. Return 1 if
a call to compare_modify_times using path as the
first parameter returns 1 with any of the elements of the paths
array. Use short-circuit evaluation so that you do not have additional
calls to compare_modify_times that are not necessary.
Write a test program, test_check_older that takes one or more command line arguments and tests check_older using these paths. Note that you should not have to make an array to pass to check_older.
Modify the makefile to compile these programs.
Handing in your program:
Use this cover sheet. Consecutively number all of
the other pages you turn in. Each page that contains your work should have
a number on it. Turn this in at the beginning of lecture on the due date.