sched: implement various ways to end tasks and threads
This commit is contained in:
@@ -11,6 +11,7 @@ static const virt_addr_t syscall_table[] = {
|
||||
SYSCALL_TABLE_ENTRY(TASK_CREATE_THREAD, task_create_thread),
|
||||
SYSCALL_TABLE_ENTRY(TASK_GET_ADDRESS_SPACE, task_get_address_space),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_START, thread_start),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_EXIT, thread_exit),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_CONFIG_GET, thread_config_get),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_CONFIG_SET, thread_config_set),
|
||||
SYSCALL_TABLE_ENTRY(VM_OBJECT_CREATE, vm_object_create),
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include <kernel/printk.h>
|
||||
#include <kernel/sched.h>
|
||||
#include <kernel/task.h>
|
||||
#include <kernel/thread.h>
|
||||
|
||||
kern_status_t sys_kern_log(const char *s)
|
||||
{
|
||||
struct task *task = current_task();
|
||||
printk("%s[%d]: %s", task->t_name, task->t_id, s);
|
||||
struct thread *thread = current_thread();
|
||||
printk("%s[%d.%d]: %s", task->t_name, task->t_id, thread->tr_id, s);
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user