Skip to content

Commit

Permalink
wfi to save CPU time on Athena
Browse files Browse the repository at this point in the history
  • Loading branch information
kaashoek committed Jul 27, 2024
1 parent 4d4d066 commit 47cdb5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kernel/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
}
}
}

Expand Down

0 comments on commit 47cdb5f

Please sign in to comment.