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
After running each of these, answer the following questions:
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:
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.