From 60edb9f72a2972e330d46e0c21ada975265e7d96 Mon Sep 17 00:00:00 2001 From: Stephen Marz Date: Sat, 25 Apr 2020 23:24:55 -0400 Subject: [PATCH] Remove the dumb done flag. --- risc_v/src/sched.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/risc_v/src/sched.rs b/risc_v/src/sched.rs index 009b5d6..2a138fc 100755 --- a/risc_v/src/sched.rs +++ b/risc_v/src/sched.rs @@ -10,8 +10,9 @@ pub fn schedule() -> usize { let mut frame_addr: usize = 0x1111; unsafe { if let Some(mut pl) = PROCESS_LIST.take() { - let mut done = false; - while !done { + // Rust allows us to label loops so that break statements can be + // targeted. + 'procfindloop: loop { pl.rotate_left(1); // let mut mepc: usize = 0; // let mut satp: usize = 0; @@ -21,7 +22,7 @@ pub fn schedule() -> usize { ProcessState::Running => { frame_addr = prc.get_frame_address(); - done = true; + break 'procfindloop; // println!("Process is running on frame 0x{:x}", frame_addr); // satp = prc.get_table_address(); // pid = prc.get_pid() as usize;