Computer Science 322
Operating Systems

Mount Holyoke College
Spring 2008


Lab 0: Getting Reacquainted with C and Unix
Due: 10:00 AM, Monday, February 4, 2008


  1. Send me mail at jteresco@mtholyoke.edu with a brief (a couple sentences) indication of your level of experience with the Unix operating system and its variants, plus a list of other operating systems you have used. Also include a list of programming languages you have used and your proficiency in each, and anything else you'd like me to know about your background coming in. (1 point)
  2. (3 points total) We will be using several Unix-based systems within the Computer Science department. Log into and familiarize yourself with your CS Unix accounts.
  3. Copy the C program here that computes the late penalties for this course to your cluster account. Compile and run it, redirecting your output to a file late.txt. (1 point)
  4. Copy the file /cluster/home/terescoj/shared/make-example.tar to your cluster account. It is a "tar file" of a small C program that demonstrates the use of multiple source files and Makefiles. Extract the files (tar xvf make-example.tar) and compile the program with make. In a plain text file called make.txt, briefly describe how make uses the rules in the Makefile to produce the executable main. (1 point)
  5. Write a C program that takes an arbitrary number of command-line parameters, each of which should represent an integer value. Print out the sum of the values provided. Call your C program argadder.c and include a Makefile that guides compilation of your program into an executable argadder. (3 points) Hint: See main.c in the make example, and note that the parameter argc to the main function is a count of how many command-line strings are included in the argv array of strings. Also, argv[0] is not the first parameter, it is the program name itself, and this array entry for the program name is included in the value of argc.

To transfer files from your Linux lab account to the cluster, you can use the scp ("secure copy") command. It works much like the standard cp command, except that you can specify hostnames for the source and/or destination files. For example, to transfer the file linux.txt from your Linux lab account to the cluster in a subdirectory cs322, open a terminal window and change to the directory that contains the file (say, cs322) and execute the command:

    scp linux.txt mhccluster.teresco.org:cs322

Alternately, you could log into mhccluster and issue the command in the opposite direction, with the same net effect:

    scp babyred.mtholyoke.edu:cs322/linux.txt .

The "." in the command indicates that the destination for the copy is your current working directory.

To submit this lab, use the turnin utility on the cluster head node, using the directions on the course home page. Please include the files linux.txt, cluster.txt, unix.txt, late.txt, make.txt, argadder.c, and Makefile in your submission.

Please use the exact filenames specified (for this lab and all semester) to make my job easier when gathering your submissions together for grading. You don't want to annoy your grader with misnamed or missing files just before he grades your assignment.