CS 3733 Operating Systems, Spring 1996 Assignment 3

When turning in assignments:

Turn in complete source code.
Use prtext to print it out.
Include the burst page as the first page turned in.
Write a statement on the first page indicating exactly what worked and what did not.
Be prepared to demonstrate that your program works.

Part 1:
From PUP, section 4.1 starting on page 147:
Do all parts except for the last two (bidirectional ring and torus).

Assignment 3, Part 1 checklist

Assignment 3, Part 1 will be returned on Tuesday, March 26, with your exam. Most of the assignments did not include enough details for me to assign your grade for this assignment. A partial grade has been assigned. That is the grade you will receive if you take no further action.

To have your assignment regraded, turn in your original graded assignment and do the follow items that apply. I must receive these by Thursday, March 28. When capturing sample output do not redirect standard output to a file. This will affect the behavior of some of the programs. Have the output go to the screen and cut and paste into a file.

1) Include your makefile.

2) Include source code for each part clearly labeled.

3) Include lint output for each part clearly labeled.

4) Describe the corrections needed to remove any lint errors.

5) Include sample output from each of the parts and describe your observations.

6) For ring1, how does it affect the output?

7) For ring2, how does it affect the output?

8) For ring3 include sample output and describe it in your own words. Make sure you use a large enough value of the second parameter.

9) For ring4 include sample output and describe how this differs from ring3.

10) For ring5 include sample output and describe how this differs from ring3.

11) For the last part, include sample output and describe the results. Are they what was expected?

---------------------------------------------------------------------------

Part 2: Modify the ring program to implement leader election as described in Section 4.5.

In the synchronous algorithm described in the text, on each cycle either a message is sent or it is not. We simulate this on our asynchronous ring by sending a message on each cycle. Send a byte containing 1 to represent a 1-bit message and send a byte of 0 to represent a cycle in which no message is sent.

I have provided routines for generating random numbers in the file ~srobbins/cs3733/randomlib.c. Call initrandom() once and then call nextran(k) to return a random integer between 1 and k.

Start by instrumenting your code to make sure it is working correctly. When the leader election is complete, have each process print a message identifying itself and giving the number of phases that the election took. Also indicate whether it was the chosen process. The processes must shut down in such a way that all of the processes can print this message. Turn in a copy of the output genterated by a run with 4 processes.

When you have you program working, make a new copy and modify the new copy so that only the chosen process prints anything. It will print only two integers on a line giving its process number (between 1 and the number of processes) and the number of phases it took for the election. Run the program 100 times for 10 processes and collect the data. Plot histograms for the winning process and the number of phases. What was the average number of phases? Do all of the numbers make sense?