diff options
| -rw-r--r-- | include/fbos/sched.h | 6 | ||||
| -rw-r--r-- | kernel/trap.c | 9 |
2 files changed, 6 insertions, 9 deletions
diff --git a/include/fbos/sched.h b/include/fbos/sched.h index 00f3e70..f43b6e5 100644 --- a/include/fbos/sched.h +++ b/include/fbos/sched.h @@ -27,10 +27,8 @@ struct task_struct { // Tasks available on this kernel. extern struct task_struct tasks[4]; -// Switch execution to the given U-mode task. Note that this function will not -// do the actual returning, but it prepares the relevant registers for an -// eventual jump. -__kernel __always_inline void switch_to(int task_id) +// Set the return address to U-mode to the given task. +__kernel __always_inline void set_return_address_to(int task_id) { asm volatile("csrc sstatus, %0\n\t" "mv t0, %1\n\t" diff --git a/kernel/trap.c b/kernel/trap.c index f98fcc7..4e31b6d 100644 --- a/kernel/trap.c +++ b/kernel/trap.c @@ -78,7 +78,7 @@ __aligned(4) __s_interrupt __kernel void interrupt_handler(void) if (IS_EXCEPTION(cause)) { exception_handler(cause); - switch_to(TASK_INIT); + set_return_address_to(TASK_INIT); goto end; } @@ -94,12 +94,11 @@ __aligned(4) __s_interrupt __kernel void interrupt_handler(void) // BEHOLD! The fizz buzz logic! :D seconds_elapsed += 1; if ((seconds_elapsed % 15) == 0) { - switch_to(TASK_FIZZBUZZ); + set_return_address_to(TASK_FIZZBUZZ); } else if ((seconds_elapsed % 5) == 0) { - switch_to(TASK_BUZZ); + set_return_address_to(TASK_BUZZ); } else if ((seconds_elapsed % 3) == 0) { - switch_to(TASK_FIZZ); - } else { + set_return_address_to(TASK_FIZZ); } // Re-enable timer interrupts. |
