From 3237db9aacacddb8daf160a3c790757ff895b501 Mon Sep 17 00:00:00 2001 From: Ry Date: Sat, 21 May 2022 17:04:39 -0700 Subject: [PATCH] fox32os: Don't mark task 0 as unused when yielding for the first time --- kernel/main.asm | 3 ++- kernel/task.asm | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/main.asm b/kernel/main.asm index 6784670..863249b 100644 --- a/kernel/main.asm +++ b/kernel/main.asm @@ -84,8 +84,9 @@ draw_startup_text: ; when the startup file yields for the first time, we'll end up back here ; jump back to it without adding this "task" (not really a task) into the queue + ; end_current_task_no_mark is used specifically because it doesn't mark the current task (still set to 0) as unused ; this does not return - call end_current_task + call end_current_task_no_mark startup_error: mov r0, BACKGROUND_COLOR diff --git a/kernel/task.asm b/kernel/task.asm index 564ccb9..8f83e74 100644 --- a/kernel/task.asm +++ b/kernel/task.asm @@ -43,13 +43,14 @@ yield_task: ; outputs: ; none end_current_task: - cmp [task_queue_ptr], task_queue_bottom - ifz jmp task_empty - mov r0, current_task ; get the current task struct call task_load bcl [task_id_bitmap], r2 ; mark this task ID as unused +end_current_task_no_mark: pop r0 ; pop the return address off of the stack + + cmp [task_queue_ptr], task_queue_bottom + ifz jmp task_empty yield_task_0: mov r0, task_queue_bottom call task_load