From 8c61fd1aa617d41f4f0b2f956c4b1aa95de446c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Autin?= Date: Tue, 9 May 2023 18:08:44 +0200 Subject: [PATCH] Fixed nobody to run --- src/kernel/thread_manager.rs | 6 +++++- .../boolean_logic/comparisons.c | 18 ++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/kernel/thread_manager.rs b/src/kernel/thread_manager.rs index e09606e..b532834 100644 --- a/src/kernel/thread_manager.rs +++ b/src/kernel/thread_manager.rs @@ -239,7 +239,11 @@ impl ThreadManager { while next_thread.is_none() { eprintln!("Nobody to run => idle"); machine.interrupt.idle(); - next_thread = self.find_next_to_run(); + if let Some(t) = self.find_next_to_run() { + next_thread = Some(t); + } else { + panic!("Couldn't find next thread to run.\nShutting down..."); + } } self.switch_to(machine, Rc::clone(&next_thread.unwrap())); diff --git a/test/riscv_instructions/boolean_logic/comparisons.c b/test/riscv_instructions/boolean_logic/comparisons.c index ec42461..ad5debf 100644 --- a/test/riscv_instructions/boolean_logic/comparisons.c +++ b/test/riscv_instructions/boolean_logic/comparisons.c @@ -1,15 +1,13 @@ int main() { int x = 0; int y = 1; - while (x <= y) { - if (x > y) { - x += 1; - } else if (x == y) { - x += y; - } else if (x < y) { - y += 1; - } else { - return 0; - } + if (x > y) { + x += 1; + } + if (x == y) { + x += y; + } + if (x < y) { + y += 1; } } \ No newline at end of file