Home | | Schedule | | Assignments | | Lecture Notes
Due: Friday, April 22, in class
Answer the following questions. Your answers should be typed (except for the Gantt diagrams, which you may draw by hand).Question 1. Briefly define each of these terms (one or two sentences each):
Question 2. Consider a concurrent system with two processes, P and Q, shown in the following code. A, B, C, D, and E are arbitrary atomic (indivisible) statements. Assume that these two processes are executing concurrently.
| Process P | Process Q |
| begin | begin |
| A; | D; |
| B; | E; |
| C; | end. |
| end. |
Question 3. Does the following solution to the critical section problem for
three processes satisfy mutual exclusion? Justify your
response.
Concurrent Flags:
There are three flags (shared variables): flag1, flag2 and flag3
There is one shared variable, sign, that is set to 1, 2 or 3, corresponding to each process.
initially: all flags are false and sign is set to 1.
Process A:
while(1) {
//do some stuff
flag1 = true;
sign = 1;
while ((flag2 || flag3)
&& (sign == 1)) {
// do nothing
}
//critical section
...
flag1 = false;
}
|
Process B:
while(1) {
//do some stuff
flag2 = true;
sign = 2;
while ((flag1 || flag3)
&& (sign == 2)) {
// do nothing
}
//critical section
...
flag2 = false;
}
|
Process C:
while(1) {
//do some stuff
flag3 = true;
sign = 3;
while ((flag1 || flag2)
&& (sign == 3)) {
// do nothing
}
//critical section
...
flag3 = false;
}
|
Question 4.
Does the following solution to the critical section problem for
two processes satisfy the following requirements for critical sections:
mutual exclusion, bounded waiting (no starvation) and progress? Justify your
response.
Concurrent Flags2:
There are two flags (shared variables): flag1 and flag2
There is one shared variable, sign, that is set to 1 or 2, corresponding to each process.
initially: both flags are false and sign is set to 1.
Process A:
while(1) {
//do some stuff
flag1 = true;
while (flag2) {
if (sign == 2) {
flag1 = false;
while (sign == 2)
; //do nothing
flag1 = true;
}
}
//critical section
...
sign = 2;
flag1 = false;
}
|
Process B:
while(1) {
//do some stuff
flag2 = true;
while (flag1) {
if (sign == 1) {
flag2 = false;
while (sign == 1)
; //do nothing
flag2 = true;
}
}
//critical section
...
sign = 1;
flag2 = false;
}
|
Question 5. Suppose a fixed partitioning memory system with partitions of 100K, 500K, 200K, 300K, and 600K (in memory order) exists. All five partitions are currently available.
Question 6. Consider a logical address space of eight pages of 1024 bytes each, mapped onto a physical memory of 32 frames.
Completed homework:
Constance Royden--croyden@mathcs.holycross.edu
Computer Science 346--Operating Systems
Date Created: January 9, 2004
Last Modified: January 7, 2005
Page Expires: January 8, 2006