diff options
author | Benji Dial <benji6283@gmail.com> | 2020-09-13 03:19:57 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2020-09-13 03:19:57 -0400 |
commit | 1e4a254674f668839e5de273916024c16814b045 (patch) | |
tree | 6774f4d4398a29c4aafb4120070975d864ffcde4 /src/kernel/task.c | |
parent | b8284137d4e0eec11c78bc14047243fce6a51373 (diff) | |
download | portland-os-1e4a254674f668839e5de273916024c16814b045.tar.gz |
(basic, not much tested) keyboard, better panic
Diffstat (limited to 'src/kernel/task.c')
-rw-r--r-- | src/kernel/task.c | 22 |
1 files changed, 12 insertions, 10 deletions
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; |