From bb16bd0a71a8e615441694b97813cda2f8ea8ff8 Mon Sep 17 00:00:00 2001 From: Ada Christine Date: Fri, 22 May 2026 00:11:54 +0000 Subject: thread termination cleanup --- kc/core/task.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'kc/core/task.c') diff --git a/kc/core/task.c b/kc/core/task.c index aa5d179..0f2149d 100644 --- a/kc/core/task.c +++ b/kc/core/task.c @@ -384,3 +384,30 @@ static int sleeping_thread_callback(uint64_t nanoseconds) return 0; } + +typedef void (locked_scheduler_action)(void *); + +static void with_locked_scheduler( + locked_scheduler_action *action, + void *action_parameter) +{ + lock_scheduler(); + action(action_parameter); + unlock_scheduler(); +} + +static void terminate_action(void *result) +{ + union kc_thread_result *result_value = result; + current_thread->result = *result_value; + current_thread->kernel_stack_pointer = current_thread->kernel_stack_head; + // TODO: wake threads waiting + // TODO: write waitng thread code + // +} + +void kct_terminate(union kc_thread_result result) +{ + with_locked_scheduler(terminate_action, &result); +} + -- cgit v1.3.1-1-g115d