The accompanying table indicates assignments and due dates for Computer Science 213 and are subject to the following notes.

Due Date Collaboration Chapter Problems
Fri., Sept. 4
Lab. Exercise 1
Fri., Sept. 11
Lab. Exercise 2
Mon., Sept. 14
Chapter 2 2.1, 2.2
Tues., Sept. 22
Lab. Exercise 3
Fri., Sept. 25
Lab. Exercise 4
Mon., Oct. 5
Sup. Prob. 1
Fri., Oct. 16
Lab. Exercise 5
Fri., Oct. 30
Lab. Exercise 6
Fri., Nov. 6
Multi-Proc. Handout 1 or 2 (not both)
Fri., Nov. 13
Lab. Exercise 7
Fri., Nov. 20
Lab. Exercise 8
Wed., Dec. 2
Take-Home Test
Fri., Dec. 11
Lab. Exercise 9

Submitting Programs For This Course: In turning in any programs for the course, please follow these directions:

  1. The first five lines of any C program should be comments containing your name, your mailbox number, and an identification of assignment being solved. For example:
         * Henry M. Walker                    *
         * Box Y-06                           *
         * Assignment for Friday, September 4 *
    Also, a comment is needed for every definition of a C function, stating in English what that program unit is supposed to do.

  2. Obtain a listing of your program and a record of relevant test runs using the submit command:
    • Within a dtterm window (before running C), begin recording session with the statement

      submit filename

      where filename is the name of the file in which you want the session stored.
    • Within the submit file,
      • Print a copy of your program with the command

        cat C-file.c

        where C-file.c is the name of the file containing your C program.
      • If your work involves several files, list the main program first with the cat command; then list any supplementary files.
      • Compile your program with the gcc command, and run it with appropriate test cases to check the correctness of your program.
    • When your runs are complete, stop the submit session by typing <Ctrl/D>.
    • Print the record of your session by typing

      print filename

  3. Either write on your printout or include a separate statement that argues why your program is correct, based upon the evidence from your test runs.
Some Grading Notes:

Supplemental Problems

  1. Organizing A Task Among Several Processes: Consider the following general programming problem, which is based on an exercise by John Stone:

    The file /home/stone/courses/scheme/Iowa-cities.dat contains information about the sixty largest cities and towns in Iowa: their names and populations, as determined by the 1990 and 1980 censuses. A typical line of the file looks like this:

    Grinnell          8902    8868
    Columns 1 through 16 contain the name of the town, left-justified; columns 17 through 22 contain the 1990 population, right-justified; columns 23 and 24 are always spaces; and columns 25 through 30 contain the 1980 population, right-justified.

    Write C programs which read data from this file and determine the answers to the following two questions:

    This supplemental problem asks you to solve this problem with three approaches:

    1. Write a C program which solves this problem with a main process doing all steps of reading the file, finding the largest decrease, and finding Iowa's rural population. All work in Main

    2. Write a C program which spawns a child process to read the file. More precisely,
      • a child process should read the file and pass data through a pipe using C's byte-oriented write statement,
      • the parent process should use C's byte-oriented read to obtain data from the pipe and to complete processing for the two questions above.
      Child reads; main analyzes

    3. Write a C program which spawns two children; the parent and both children then should collaborate to perform this work. Overall, the parent process will read the file and send a copy of each line through a pipe to each child. Each child will answer one of the above questions. More precisely,
      • The parent process should use popen to create one child processs. The parent then should send formatted data to that child using the file descriptor returned by popen,
      • The one child process (created by popen) should read from standard input and run a program to determine the city with the greatest percentage decrease in population,
      • The parent process also should use pipe and fork to create a second child process connected to the parent by a pipe. The parent then should bind one end of this pipe to the parent's standard output and send a copy of the formatted file data through this pipe, and
      • The second child process (created with pipe and fork) should bind its standard input to the pipe, so this process can read formatted data directly from the pipe and compute the rural population directly (without executing another program).
      Main reads; each child analyzes one result

This document is available on the World Wide Web as

created August 31, 1998
last revised November 10, 1998