From 93c7cf19954a1d1c726bbe0ffd742561c916f716 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 26 May 2009 17:02:32 +0300 Subject: [PATCH] Fixed fork() errors where forked thread is a copy of any cloned thread in parent address space. Upon fork, child was created in a new space but as a copy of any cloned thread in the parent space. This was due to the search of forker thread by its space id (which is shared among many cloned threads). Now fixed. modified: src/api/thread.c modified: tasks/mm0/src/task.c --- src/api/thread.c | 2 +- tasks/mm0/src/task.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/thread.c b/src/api/thread.c index fc90ce9..a81842e 100644 --- a/src/api/thread.c +++ b/src/api/thread.c @@ -309,7 +309,7 @@ int thread_create(struct task_ids *ids, unsigned int flags) return -ENOMEM; if (flags == THREAD_SAME_SPACE || flags == THREAD_COPY_SPACE) { - if (!(orig_task = tcb_find_by_space(ids->spid))) { + if (!(orig_task = tcb_find(ids->tid))) { /* Pre-mature tcb needs freeing by free_page */ free_page(new); return -EINVAL; diff --git a/tasks/mm0/src/task.c b/tasks/mm0/src/task.c index e069db0..02c6268 100644 --- a/tasks/mm0/src/task.c +++ b/tasks/mm0/src/task.c @@ -308,7 +308,7 @@ struct tcb *task_create(struct tcb *parent, struct task_ids *ids, /* Set task ids if a parent is supplied */ if (parent) { - ids->tid = TASK_ID_INVALID; + ids->tid = parent->tid; ids->spid = parent->spid; /*