sched: task: implement task creation flags
This commit is contained in:
+15
-5
@@ -172,10 +172,12 @@ struct task *task_alloc(void)
|
||||
}
|
||||
|
||||
struct task *task_create(
|
||||
struct task *parent,
|
||||
task_flags_t task_flags,
|
||||
const char *name,
|
||||
size_t name_len,
|
||||
struct handle_table *handles)
|
||||
size_t name_len)
|
||||
{
|
||||
kern_status_t status = KERN_OK;
|
||||
struct task *task = task_alloc();
|
||||
if (!task) {
|
||||
return NULL;
|
||||
@@ -194,13 +196,21 @@ struct task *task_create(
|
||||
VM_USER_LIMIT,
|
||||
&task->t_address_space);
|
||||
|
||||
if (!handles) {
|
||||
handles = handle_table_create();
|
||||
if (task_flags & TASK_F_CLONE_ALL_HANDLES) {
|
||||
status = handle_table_duplicate(
|
||||
parent->t_handles,
|
||||
&task->t_handles);
|
||||
} else {
|
||||
task->t_handles = handle_table_create();
|
||||
}
|
||||
|
||||
if (status != KERN_OK) {
|
||||
object_unref(&task->t_base);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task->t_address_space->s_pmap = pmap;
|
||||
task->t_state = TASK_RUNNING;
|
||||
task->t_handles = handles;
|
||||
|
||||
if (name) {
|
||||
name_len = MIN(name_len, sizeof task->t_name - 1);
|
||||
|
||||
Reference in New Issue
Block a user