From 6d8f2d0e93228a1aaecace14eb345fe1224b211f Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 22 Aug 2021 13:06:26 +0200 Subject: process_switch_any: deduplicate some code --- src/kernel/proc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/kernel/proc.c') 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 #include +#include #include #include #include @@ -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) { -- cgit v1.2.3