Computer Science 432
Operating Systems

Williams College
Fall 2006


Lab 3: Process Interleavings
Due: 11:59 PM, Tuesday, October 10, 2006


A very short lab assignment this week leading up to the Reading Period and the first exam. This lab is a "laboratory program" for honor code purposes (no groups for this one). You may discuss the program with others, but what you turn in must be your own work.

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.

Submission and Evaluation

All necessary files should be submitted using turnin as a single "tar" file, lab3.tar. Include a Makefile to allow easy compilation of the C program.