Lab 3 - Critical Sections
Due: 9:55 AM, Tuesday, March 1, 2005


This week's lab consists of questions to look at on your own (not to be turned in) and some questions to be turned in. The programing for this lab is considered a "laboratory program" for honor code purposes. You may discuss the programs with others, but what you turn in must be your own work.

Practice Questions

You do not need to turn in answers to these questions. But they could certainly form the basis for potential exam questions.

Lab Questions

Answer these questions in a plain text file named lab3.txt.

  1. List two enhancements that could be implemented in your round robin simulator from Lab 2 that would allow a more realistic simulation or allow the simulation of more sophisticated scheduling algorithms. For each, describe briefly what your enhancement would allow the simulator to do, and how you would go about implementing it. (2 points)
  2. SG&G 6.1 (3 points)

Process Interleavings

Write a C program that will list all possible orderings of the machine instructions generated for the critical sections of the Producer-Consumer example from class. Recall that the statements counter++ and counter- actually generate machine code such as

Producer Consumer
P1 R0 = counter; C1 R1 = counter;
P2 R0 = R0 + 1; C2 R1 = R1 - 1;
P3 counter = R0; C3 counter = R1;

Your program should list all possible interleavings of the statements P1, P2, P3, C1, C2, and C3. Also have your program print which interleavings produce a correct result (that counter has the same value it started with).

Write your program in a file called interleaving.c. (5 points)

Submission and Evaluation