CS 3733 Operating Systems, Fall 2001 Assignment 3


Due Wednesday, October 24, 2001


In this assignment you will use the ring simulator to explore process scheduling and synchronization. Read the exercises after Program 4.1 in the text to get a feel for the problem. However, you will just be using the simulator and do not have to compile any programs.

Make a directory called assign3 for all of the files for this assignment.


Part 0
Copy all of the files from /usr/local/courses/java/ringfiles into your assign3 directory. Modify the ringconfig file so the the user line contains your name instead of Local User. Make sure that /usr/local/courses/java/bin is in your path and run the ring simulator using
runring

The simulator should come up and you should be able to create a log file.


Part 1
Open a log file and keep a log of the output generated for each set of runs described below. You can display the output generated by the simulated program by clicking on the Show Output button. Run the program several times (at least 3) with the configuration indicated and put the resulting output in the log file. Push the Reset button between runs. After logging the output, push the clr button on the output window before starting the next set of runs.

Try each of the following and record the output generated by the simulated program.

After each of these, change back to the standard configuration:
After fork: parent
Choose Process: FCFS
Scheduling: no preempt
Print Atomic

  1. The standard configuration.
  2. Change After fork from parent to child.
  3. Change After fork from parent to either.
  4. Change After fork from parent to random.
  5. Change Choose Process from FCFS to Random.
  6. Change Scheduling from no preempt to round robin with a quantum of 5 and Choose Process from FCFS to Random.
  7. Repeat the experiment above with different values of the quantum and see if any of them behave differently.
  8. Change Print Atomic to Print Not Atomic
  9. Insert a Wait call before the fprintf statement.
  10. Change Print Atomic to Print Not Atomic and insert a Wait call before the fprintf statement.
You do not have to put all 10 runs in the same log file, but remember to change the name of the log file so you do not overwrite previous ones.

After running each of these, answer the following questions:

  1. Was the output in the same order each time it was run?
  2. Is the order of the output determined by the program?
  3. Why do you think the output was in the order that it was?


Part 2
Now perform two runs of the simulator, one in which the child breaks out of the loop instead of the parent, and one in which neither process breaks out.
For each of these:

  1. Determine the relationship between the processes and the pipes. Do they still form a ring?
  2. Determine the parent-child relationship among the processes. Do we still have a process chain?
For each of these, create a log file containing the output generated and diagrams of the processes and pipes. Include the diagram generated by running the simulator and also a modified diagram in which you have moved the processes and pipes (if necessary) to show the relationships. To answer the second question, use the third Show button in the 5th column to hide the pipes and file descriptors and show only the processes and parent-child relationships. (You need to be running at least version 0.21.)

Use the cover sheet to hand in your assignment. Your log file can be in several parts, but number the pages consecutively and fill in the index on the cover sheet. Then answer the questions on the cover sheet.


Extra Credit 1: (2 points)
Use the simulator to add code to the standard ring so that a token is passed around the ring before the fprintf statement. The fprintf is executed only when the process has the token. The token can be any string. The first process should start by outputting its message to standard error and then start the token on its way by writing a string to standard output. The other processes first read the string, do the fprintf, and then write the string to the ring. Run this both with Print Atomic and Print Not Atomic and describe the results. Put the output and a copy of the program in a log file. Comment on the output generated. If the output includes a message about SIGPIPE, explain why you think it is there and what needs to be done to eliminate it.

Note: Using the Toggle if(i==1) button in program mode you can make statements that are executed only by the first process or by all processes except the first one.


Extra Credit 2 (1 point)
Use the ring simulator to try to make a bidirectional ring. If you are successful, use the Log button above the program to put a copy of the program in the log file. Use the Log Image button to put a picture of the ring created into the log file. Be sure to move around the processes and pipes if necessary to make it clear that it is a bidirectional ring.