wfi to save CPU time on Athena
This commit is contained in:
parent
4d4d066d9f
commit
47cdb5f096
1 changed files with 6 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue