diff options
author | dzwdz | 2021-08-22 13:06:26 +0200 |
---|---|---|
committer | dzwdz | 2021-08-22 13:06:26 +0200 |
commit | 6d8f2d0e93228a1aaecace14eb345fe1224b211f (patch) | |
tree | 0ebe732053873fe85a52b64b1af2cac0ed27dbc9 /src/kernel/proc.c | |
parent | 374e6d244f184056d64fd02729a7badf02991e29 (diff) |
process_switch_any: deduplicate some code
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r-- | src/kernel/proc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index bdd92ba..e1b650c 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -1,5 +1,6 @@ #include <kernel/arch/generic.h> #include <kernel/mem.h> +#include <kernel/panic.h> #include <kernel/proc.h> #include <kernel/util.h> #include <stdint.h> @@ -54,6 +55,15 @@ void process_switch(struct process *proc) { sysexit(proc->regs); } +_Noreturn void process_switch_any() { + struct process *found = process_find(PS_RUNNING); + if (found) + process_switch(found); + + tty_const(" no running processes left..."); + panic(); +} + // TODO there's no check for going past the stack - VULN struct process *_process_find_recursive( enum process_state target, struct process *iter) { |