CS 3733 Operating Systems, Spring 1997 Assignment 4
Preliminary Announcement


Parts 0 and 1 should be done by April 8.
Parts 2 and 3 are due on Friday, April 18 at noon.



You are going write a simplified parallel make utility in several forms.

Part 0: Make a web page and register it.

To do this, access http://www.cs.utsa.edu and follow the following links:
Students, CS Division Student Directory, directions.

Alternatively, you can just click here

Part 1: Children Compile, Parent Links

Write a main program, comp_link, which takes 2 or more command line arguments. The first command line argument is the name of an executable to create. The other arguments are the names of C source files.

The main program will fork a child for each source file and the child will create an object file by invoking the C compiler as in:

   cc -c filename.c
The parent process will wait for all of the children to finish and if they are all successful, it will link the object files to produce the executable by invoking the C compiler as in:
   cc -o executable file1.o file2.o ...
The children should do the compile concurrently. You must find a way for the parent to determine whether the children were successful. All error messages should go to the screen.

Answer the following questions:

  1. How did you implement the communication about success from the child to the parent?
  2. Compare the time it would take to compile all of the modules with your program and the time for the standard make utility. Give a general theoretical answer, do not make measurements. Consider the case of a single CPU system and a multiple CPU system.

Extra Credit: Devise a method which will allow the children to output their error messages atomically so that you can tell which compile caused each error message. Explain the method you used.

Part 2: Independent Processes Compile, Another Links

Write a program, compile_it which takes two command line arguments, the name of a source file and a process ID. The program creates an object file for the given source file and sends a SIGURS1 signal to the process with the given process ID if the compile was successful.

Write a program, link_it which takes command line arguments like the comp_link program. If first prints its process ID. Then it waits for the appropriate number of SIGUSR1 signals and then links the files together producing an executable.

Test your programs by compiling and linking three modules together by first starting link_it and then calling three copies of compile_it, one for each module. Run all programs from the same directory, but in different windows.

Note that link_it does not exit oif a module has a compile error. This allows for the correction and recompilation of that module without restarting link_it.

Answer the following question:

  1. What happens if two or more processes finish their compiles and send signals to link_it while link_it is waiting for the CPU? Will this still work?

Part 3: Daemon Compiles, Another Links

Create named pipe called fileinfo in the directory in which you have your programs for this part. You will use the name of this pipe as a command line argument int the programs discussed below

Write a daemon process, compile_any, which takes one command line argument, the name of a named pipe, and prints its process ID. It then waits for a SIGUSR1 realtime signal and when it comes in, forks a child process to compile a C source file into an object module. After the fork, it should wait for additional signals to come in so it can start other compiles. The child reads a filename from the named pipe which was the command line argument and sends a SIGURS2 signal back indicating that the read from the pipe was complete. It gets the process ID of the process to send to from the information in the realtime SIGURS1 signal its parent received. The child then creates an object module for that file. When the compilation is done, it sends a realtime SIGUSR1 signal back as in Part 2, but this time the info field indicates whether the compile was successful. The child then exits.

Write a main program, par_compile which takes 4 or more command line arguments. The first argument is the process ID of the compile_any daemon, the second is the name of a named pipe, and the others are as in Part 1. This program causes compile_any to compile the indicated files and notify it when each compile is done as described above. When all are successful, it links the modules. If one or more of the modules does not compile successfully, it exits with an appropriate message.

Answer the following questions:

  1. What happens if two or more processes finish their compiles and send signals to par_compile while par_compile is waiting for the CPU? Will this still work?
  2. What would happen if several par_comile programs tried to use the same compile_any at the same time. Under what conditions would this would and under what conditions would it fail?
Extra Credit: Devise and implement a method which will not require the process ID of the daemon to be passed on the command line to par_compile. Explain the main idea behind your implementation.