Dining Philosopher Problem
Dining Philosopher Problem
take_fork(i) {
Philosopher i P(mutex);
state[i] = hungry;
test(i) {
do { test(i);
if(state[i] == hungry
/* think */ V(mutex);
&& state[(i+1)%N] != eating
take_fork(i); P(s[i]);
&& state[(i-1+N)%N != eating)
/* eat */ }
{
put_fork(i); state[i] = eating;
/* think */ put_fork(i) {
V(s[i]);
} while(true); P(mutex);
}
state[i] = thinking;
test(LEFT);
test(RIGHT)%N);
V(mutex);
}
Memory Management
Page and Frame Replacement Algorithms
Proportional allocation
Allocate according to the size of process
Computation proceeds as follows:
si = size of process pi and
S = si
m = total number of frames
s si
ai = allocation for pi = m
S
Priority Allocation
Time
Working-Set Model
Local replacement – each process selects from only its own set of
allocated frames
More consistent per-process performance
But possibly underutilized memory