sched: implement various ways to end tasks and threads

This commit is contained in:
2026-03-18 21:07:43 +00:00
parent e03b2e07d0
commit 4551e7b2e6
12 changed files with 148 additions and 17 deletions

View File

@@ -10,11 +10,8 @@ extern kern_status_t sys_task_exit(int status)
{
struct task *self = current_task();
printk("%s[%d]: task_exit(%d)", self->t_name, self->t_id, status);
while (1) {
milli_sleep(5000);
}
return KERN_UNIMPLEMENTED;
task_exit(status);
return KERN_FATAL_ERROR;
}
kern_status_t sys_task_self(kern_handle_t *out)
@@ -179,6 +176,7 @@ kern_status_t sys_task_create_thread(
&target_handle,
&out_handle);
if (status != KERN_OK) {
object_unref(target_obj);
task_unlock_irqrestore(self, flags);
return status;
}
@@ -198,10 +196,11 @@ kern_status_t sys_task_create_thread(
}
thread_init_user(thread, ip, sp, args, nr_args);
target_handle->h_object = &thread->thr_base;
object_add_handle(&thread->thr_base);
target_handle->h_object = &thread->tr_base;
object_add_handle(&thread->tr_base);
task_unlock_irqrestore(target, flags);
object_unref(target_obj);
*out_thread = out_handle;
return KERN_OK;
@@ -288,6 +287,13 @@ kern_status_t sys_thread_start(kern_handle_t thread_handle)
return KERN_OK;
}
kern_status_t sys_thread_exit(void)
{
thread_exit();
/* unreachable */
return KERN_FATAL_ERROR;
}
kern_status_t sys_thread_config_get(
kern_handle_t thread_handle,
kern_config_key_t key,