diff options
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); +} + |
