-
-
-
CENAPAD-MGCO
A seguir: Multiprocessadores
Acima: Chaves e Camas
Anterior: Chaves
class Bed {
Queue waiting;
}
void wait(Bed b, Key k) {
InterruptStatus is = saveInterruptStatus();
disableInterrupts();
currentProcess.state = WAITING;
unlock(k);
b.waiting.put(currentProcess);
transfer(currentProcess.coroutine, kernel);
is.restore();
}
void wakeup(Bed b, Key k) {
InterruptStatus is = saveInterruptStatus();
disableInterrupts();
while ((Process p = b.waiting.get()) != null) {
p.state = WAITING;
k.waiting.put(p);
}
is.restore();
}