CS520
Spring 2014
Laboratory 9
Monday March 31
The lab must be submitted prior to 8am on Tuesday April 1.


Write a program that will take a list of filenames on the command-line. If the list is empty, print an error message and exit. The goal is to compute how many lines are in each file using a Posix thread for each file.

Create a Posix thread for each argument given on the command-line. Each thread should open its filename. If the open fails, the thread should print an error message and terminate. If the open succeeds, the thread should read the file and count the number of newlines. When EOF is reached, the thread should print its filename with the number of newlines in the file, and terminate the message with a newline. The thead can then exit.

You can use the code in ~cs520/public/prog5/count.c if you wish. (You can also use this code on Lab 10 and Program 5.)

Please turn-off any debugging code before you submit your lab.

  • Submit your lab via:
    ~cs520/bin/submit lab9 lab9.c

  • Submissions can be checked by typing:
    ~cs520/bin/scheck lab9


    Last modified on March 27, 2014.

    Comments and questions should be directed to hatcher@unh.edu