kernel: services: resume correct context after interrupt

We were resuming the wrong context after returning from an interrupt.
This resulted in us resuming context 3 more often than not.

This now properly banks the current process context prior to the switch.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-03-27 16:58:04 +08:00
parent 405a9227cf
commit 6b729d9ebc

View file

@ -328,6 +328,7 @@ impl SystemServices {
ProcessState::Running(x) => ProcessState::Ready(x),
y => panic!("current process was {:?}, not 'Running(_)'", y),
};
current.current_context = current.previous_context;
}
// Get the new process, and ensure that it is in a state where it's fit
@ -393,6 +394,7 @@ impl SystemServices {
ProcessState::Setup(_, _, _) => panic!("process hasn't been set up yet"),
};
process.state = ProcessState::Running(available_threads);
process.previous_context = process.current_context;
process.current_context = IRQ_CONTEXT as u8;
process.mapping.activate();
}
@ -593,8 +595,6 @@ impl SystemServices {
// Restore the previous context, if one exists.
process.set_context_nr(new_context);
self.processes[self.pid as usize - 1].previous_context =
self.processes[self.pid as usize - 1].current_context;
self.processes[self.pid as usize - 1].current_context = new_context as u8;
let ctx = process.current_context();
println!(