next up previous
Next: Resumo e Conclusões Up: Chaves e Camas Previous: Chaves

Camas

 
class Bed {

Queue waiting; }

void sleep(Bed b, Key k) {

InterruptStatus is = saveInterruptStatus(); disableInterrupts();

currentProcess.state = SLEEPING;

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();

}



Osvaldo Sergio F. de Carvalho
Wed Mar 19 14:56:39 EST 1997