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:
Bahadir Balban
2008-11-19 21:34:57 +02:00
parent 46937eab88
commit 1914e58be9
2 changed files with 38 additions and 9 deletions

View File

@@ -58,11 +58,12 @@ int sys_fork(struct tcb *parent)
int err;
struct tcb *child;
struct exregs_data exregs;
struct task_ids ids = {
.tid = TASK_ID_INVALID,
.spid = parent->spid, /* spid to copy from */
.tgid = TASK_ID_INVALID, /* FIXME: !!! FIX THIS */
};
struct task_ids ids;
// = {
// .tid = TASK_ID_INVALID,
// .spid = parent->spid, /* spid to copy from */
// .tgid = TASK_ID_INVALID, /* FIXME: !!! FIX THIS */
// };
/* Make all shadows in this task read-only */
vm_freeze_shadows(parent);
@@ -108,8 +109,8 @@ int do_clone(struct tcb *parent, unsigned long child_stack, unsigned int flags)
struct tcb *child;
int err;
ids.tid = TASK_ID_INVALID;
ids.spid = parent->spid;
//ids.tid = TASK_ID_INVALID;
//ids.spid = parent->spid;
/* Determine whether the cloned thread is in parent's thread group */

View File

@@ -274,6 +274,21 @@ struct tcb *task_create(struct tcb *parent, struct task_ids *ids,
struct tcb *task;
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 */
if ((err = l4_thread_control(THREAD_CREATE | ctrl_flags, ids)) < 0) {
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);
/* Set up parent-child relationship */
list_add_tail(&task->child_ref, &parent->children);
task->parent = parent;
if ((share_flags & TCB_SHARED_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 {
struct tcb *pager = find_task(PAGER_TID);