Computer Science 322
Operating Systems

Mount Holyoke College
Spring 2008

Lab 3: Process Interleavings
Due: 10:00 AM, Monday, March 3, 2008

A very short lab assignment this week leading up to the first exam. 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 in a directory named lab3. Include a Makefile to allow easy compilation of the C program.