|
Computer Science 322 Operating Systems Mount Holyoke College Spring 2010
|
|
Lecture 10: Critical Sections
Date: Monday, March 8, 2010
Agenda
- Announcements
- CPU scheduling lab updated due dates
- Take-home exam after break. Tentative schedule: out during
class Wednesday 3/24, due back Friday 3/26.
- The Critical Section Problem
- Software solutions for 2 processes
- Bakery Algorithm
- Hardware support for process synchronization
- atomic test-and-set
- bounded wait using atomic test-and-set
Lecture Assignment 10
Due at the start of class, Wednesday, March 10.
Please submit answers to these questions
either as a hard copy (typeset or handwritten are OK) or by email to
jteresco AT mtholyoke.edu by the start of class. We will discuss these questions at
the start of class, so no late submissions are accepted.
- SG&G Exercise 6.9, p. 268-269.
- SG&G Exercise 6.11, p. 269.
-
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.