I wanted to change the dynamic dispatch in process_ret() to use a DoesScheduling trait object instead of assuming the scheduler is the CoopScheduler type.
diff --git a/src/scheduling/cooperative_scheduler.rs b/src/scheduling/cooperative_scheduler.rs
index d65b2ab..4a1fbce 100644
--- a/src/scheduling/cooperative_scheduler.rs
+++ b/src/scheduling/cooperative_scheduler.rs
@@ -34,7 +34,7 @@ impl DoesScheduling for CoopScheduler {
let stack_values: Vec<usize> = vec![
new_proc as usize,
process::process_ret as usize,
- self as *const Scheduler as usize,
+ self as *const DoesScheduling as *const usize as usize,
];
for (i, val) in stack_values.iter().enumerate() {
diff --git a/src/scheduling/process.rs b/src/scheduling/process.rs
index 60189a8..2077a17 100644
--- a/src/scheduling/process.rs
+++ b/src/scheduling/process.rs
@@ -98,7 +98,7 @@ impl Process {
pub unsafe extern "C" fn process_ret() {
use scheduling::{DoesScheduling, Scheduler};
- let scheduler: &mut Scheduler;
+ let scheduler: &DoesScheduling;
asm!("pop $0" : "=r"(scheduler) : : "memory" : "intel", "volatile");
let curr_id: ProcessId = scheduler.getid();
However, running this code results in a rustc crash due to an invalid memory reference:
I wanted to change the dynamic dispatch in
process_ret()
to use aDoesScheduling
trait object instead of assuming the scheduler is theCoopScheduler
type.However, running this code results in a
rustc
crash due to an invalid memory reference: