Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/kernel/proc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ pub fn scheduler() -> ! {
// Avoid deadlock by ensuring thet devices can interrupt.
intr_on();

let mut found : bool = false;
for p in PROCS.pool.iter() {
let mut inner = p.inner.lock();
if inner.state == ProcState::RUNNABLE {
Expand All @@ -682,6 +683,16 @@ pub fn scheduler() -> ! {
// Process is done running for now.
// It should have changed its p->state before coming back.
c.proc.take();
found = true;
}
}
if found == false {
intr_on();
// If pool cycle ran without a process running...
// ...park cpu until interrupt
// This prevents cpu from red-lining for no reason
unsafe {
asm!("wfi");
}
}
}
Expand Down