mirror of
https://github.com/drasko/codezero.git
synced 2026-07-20 06:05:24 +02:00
Moved thread id assignment to task_create for new tasks with parents.
Added shared parenting for CLONE_THREAD and CLONE_PARENT
This commit is contained in:
@@ -58,11 +58,12 @@ int sys_fork(struct tcb *parent)
|
|||||||
int err;
|
int err;
|
||||||
struct tcb *child;
|
struct tcb *child;
|
||||||
struct exregs_data exregs;
|
struct exregs_data exregs;
|
||||||
struct task_ids ids = {
|
struct task_ids ids;
|
||||||
.tid = TASK_ID_INVALID,
|
// = {
|
||||||
.spid = parent->spid, /* spid to copy from */
|
// .tid = TASK_ID_INVALID,
|
||||||
.tgid = TASK_ID_INVALID, /* FIXME: !!! FIX THIS */
|
// .spid = parent->spid, /* spid to copy from */
|
||||||
};
|
// .tgid = TASK_ID_INVALID, /* FIXME: !!! FIX THIS */
|
||||||
|
// };
|
||||||
|
|
||||||
/* Make all shadows in this task read-only */
|
/* Make all shadows in this task read-only */
|
||||||
vm_freeze_shadows(parent);
|
vm_freeze_shadows(parent);
|
||||||
@@ -108,8 +109,8 @@ int do_clone(struct tcb *parent, unsigned long child_stack, unsigned int flags)
|
|||||||
struct tcb *child;
|
struct tcb *child;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
ids.tid = TASK_ID_INVALID;
|
//ids.tid = TASK_ID_INVALID;
|
||||||
ids.spid = parent->spid;
|
//ids.spid = parent->spid;
|
||||||
|
|
||||||
|
|
||||||
/* Determine whether the cloned thread is in parent's thread group */
|
/* Determine whether the cloned thread is in parent's thread group */
|
||||||
|
|||||||
@@ -274,6 +274,21 @@ struct tcb *task_create(struct tcb *parent, struct task_ids *ids,
|
|||||||
struct tcb *task;
|
struct tcb *task;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
/* Set task ids if a parent is supplied */
|
||||||
|
if (parent) {
|
||||||
|
ids->tid = TASK_ID_INVALID;
|
||||||
|
ids->spid = parent->spid;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine whether the cloned thread
|
||||||
|
* is in parent's thread group
|
||||||
|
*/
|
||||||
|
if (share_flags & TCB_SHARED_TGROUP)
|
||||||
|
ids->tgid = parent->tgid;
|
||||||
|
else
|
||||||
|
ids->tgid = TASK_ID_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create the thread structures and address space */
|
/* Create the thread structures and address space */
|
||||||
if ((err = l4_thread_control(THREAD_CREATE | ctrl_flags, ids)) < 0) {
|
if ((err = l4_thread_control(THREAD_CREATE | ctrl_flags, ids)) < 0) {
|
||||||
printf("l4_thread_control failed with %d.\n", err);
|
printf("l4_thread_control failed with %d.\n", err);
|
||||||
@@ -301,8 +316,21 @@ struct tcb *task_create(struct tcb *parent, struct task_ids *ids,
|
|||||||
copy_tcb(task, parent, share_flags);
|
copy_tcb(task, parent, share_flags);
|
||||||
|
|
||||||
/* Set up parent-child relationship */
|
/* Set up parent-child relationship */
|
||||||
list_add_tail(&task->child_ref, &parent->children);
|
if ((share_flags & TCB_SHARED_PARENT) ||
|
||||||
task->parent = parent;
|
(share_flags & TCB_SHARED_TGROUP)) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On these conditions child shares
|
||||||
|
* the parent of the caller
|
||||||
|
*/
|
||||||
|
list_add_tail(&task->child_ref,
|
||||||
|
&parent->parent->children);
|
||||||
|
task->parent = parent->parent;
|
||||||
|
} else {
|
||||||
|
list_add_tail(&task->child_ref,
|
||||||
|
&parent->children);
|
||||||
|
task->parent = parent;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
struct tcb *pager = find_task(PAGER_TID);
|
struct tcb *pager = find_task(PAGER_TID);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user