MCS-378 Homework 1, Fall 1999

Due: September 20, 1999

  1. The file forker.c which is linked to the web version of this homework contains a simple program that loops three times, each time calling the fork system call described in section 4.3.1 of the textbook. Afterwards it sleeps (does nothing) for 30 seconds. Download this file, compile it using the command
    cc -o forker forker.c
    and then run it using the command
    While the program is in its 30 second sleep, in a second terminal window do the command
    ps x
    to get a listing of processes. How many processes are shown running the ./forker command? Explain.

  2. Consider two variants of the program given in the textbook's Figure 4.8. In one variant, the line
    printf("Child Complete");
    has been removed. In the other variant, both that line and also the preceding line
    have been removed. Each of these variant programs is compiled and run in a shell terminal window. What difference might be observed between the two programs' behaviors? Explain. You are welcome to try the experiment if you would like.

Instructor: Max Hailperin