wfi to save CPU time on Athena

This commit is contained in:
Frans Kaashoek 2020-09-02 17:17:15 -04:00
parent 4d4d066d9f
commit 47cdb5f096

View file

@ -454,6 +454,7 @@ scheduler(void)
// processes are waiting.
intr_on();
int found = 0;
for(p = proc; p < &proc[NPROC]; p++) {
acquire(&p->lock);
if(p->state == RUNNABLE) {
@ -467,9 +468,14 @@ scheduler(void)
// Process is done running for now.
// It should have changed its p->state before coming back.
c->proc = 0;
found = 1;
}
release(&p->lock);
}
if(found == 0) {
intr_on();
asm volatile("wfi");
}
}
}