diff options
| author | Ada Christine <adachristine18@gmail.com> | 2026-05-22 00:11:54 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2026-05-22 00:11:54 +0000 |
| commit | bb16bd0a71a8e615441694b97813cda2f8ea8ff8 (patch) | |
| tree | ea9b83d16d110dd40e7120baa829a3793fbecd25 /kc/core/task.c | |
| parent | edc42358664e9d70227e274273321ab032394a7e (diff) | |
thread termination cleanup
Diffstat (limited to 'kc/core/task.c')
| -rw-r--r-- | kc/core/task.c | 27 |
1 files changed, 27 insertions, 0 deletions
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); +} + |
