From 1e4a254674f668839e5de273916024c16814b045 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 13 Sep 2020 03:19:57 -0400 Subject: (basic, not much tested) keyboard, better panic --- src/kernel/task.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/kernel/task.c') diff --git a/src/kernel/task.c b/src/kernel/task.c index 2a1f4c4..e2c19ca 100644 --- a/src/kernel/task.c +++ b/src/kernel/task.c @@ -70,24 +70,26 @@ void new_task(struct task_state state) { tasks[n] = state; return; } - panic("Maximum number of tasks reached."); + PANIC("Maximum number of tasks reached."); } void advance_active_task() { - struct task_state *prev_task = active_task; - do { + do if (++active_task == tasks + MAX_TASKS) active_task = tasks; - if (active_task == prev_task) { - set_log_mode(LOG_SYSTEM); - logsz("No active tasks, halting."); - while (1) - asm ("hlt"); - } - } while (!active_task->page_directory); } +void make_sure_tasks() { + for (uint8_t n = 0; n < MAX_TASKS; ++n) + if (tasks[n].page_directory) + return; + set_log_mode(LOG_SYSTEM); + logsz("No active tasks, halting."); + while (1) + asm ("hlt"); +} + void delete_task(struct task_state *state) { free_task_pd(state->page_directory); state->page_directory = 0; -- cgit v1.2.3