aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-05-14 10:01:41 +0200
committerHimbeer <himbeer@disroot.org>2024-05-14 10:01:41 +0200
commit6cf1d26dab3cdefeaa221a0e5499f87e0a2cc7eb (patch)
tree71acdbaf6e5afe61785e4aff30b4ffcc9b3422c6 /src
parent6bfb99b969621fd51fde4562a09a78f363297b18 (diff)
process: Update state when trapping or context switching
Diffstat (limited to 'src')
-rw-r--r--src/interrupts.zig1
-rw-r--r--src/process.zig4
2 files changed, 4 insertions, 1 deletions
diff --git a/src/interrupts.zig b/src/interrupts.zig
index 9d47934..eb42ff1 100644
--- a/src/interrupts.zig
+++ b/src/interrupts.zig
@@ -130,6 +130,7 @@ export fn handleTrap(epc: usize, tval: usize, cause_bits: usize, hart_id: usize,
// before returning into it.
process.list.last.?.data.pc = epc;
+ process.list.last.?.data.state = .waiting;
schedule() catch |err| {
std.debug.panic("Hart {d}: Unable to schedule next process: {any}", .{ hart_id, err });
diff --git a/src/process.zig b/src/process.zig
index 690f4f3..13281e3 100644
--- a/src/process.zig
+++ b/src/process.zig
@@ -92,7 +92,9 @@ pub fn next() ?*Info {
return null;
}
-pub fn switchTo(proc: *const Info) noreturn {
+pub fn switchTo(proc: *Info) noreturn {
+ proc.state = .active;
+
instructions.setSscratch(@intFromPtr(&proc.trap_frame));
asm volatile (