CS 3733 Operating Systems, Spring 2000 Assignment 5


Due Friday, April 7

In this assignment you will use the routines you wrote in Assignment 4 to have a collection of processes attempt to use the audio device concurrently.

Part 1
Make a directory for this assignment. Get a copy of Program 4.1 from /usr/local/courses/cs3733/pup/ch04. This is called ring.c. Modify it so that it prints out a message to standard error in the form:
This program was written by yourname
before the first pipe is created. Run the program a few times with 4 to 10 processes and get a feel for what it does. Think about the order in which the messages are displayed on the screen. Print out the result for 4 processes and explain why the output is in the order it is in.

Part 2
Copy ring.c into ring2.c. Modify it so that instead of using fprintf directly, you create a string with sprintf and send to string to the function:

void display_it(char *str) {
   fprintf(stderr,"%s\n",str);
}
Note that display_it adds in the newline, so the string you create should not include the newline character. Use display_it for both displaying your name at the beginning of the program and the message containing the process IDs at the end of the program. Run the program again for 4 processes, print out the output and explain any changes from Part 1.

Part 3
Copy ring2.c into ring3.c. Modify it so that it takes an additional integer command line parameter, a delay time. Modify display_it so that it takes a second integer parameter, delay. The new version will look like this:

void display_it(char *str, int delay) {
   fprintf(stderr,"%s\n",str);
   play_sentence(str,delay);
} 
Link this with your routines from Assignment 4. Run the program with 4 processes and various delays between 0 and 100 milliseconds. Print the output for a few of these and describe what it sounds like. Explain how the output (printed and audio) is affected by the delay.

Part 4
Copy ring3.c into ring4.c. Modify it so that a wait (wait for child) is inserted before the final call to display_it. Run the program as you did on Part 3, print out output and desribe what it sounds like. Explain the behavior.

Hand in all of your source files and the answers to the questions. Use the cover sheet in usr/local/courses/cs3733/spring2000/cover5.ps.