From f4d9520fef08c19cfa4759e5de0bf97e80327242 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 11 Aug 2009 11:23:26 +0300 Subject: [PATCH] First working Codezero & POSIX Services with container/capability changes --- include/l4/generic/tcb.h | 7 ------- src/api/thread.c | 17 +++++++++++------ src/generic/tcb.c | 11 +++++++++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h index cba971c..8428dc9 100644 --- a/include/l4/generic/tcb.h +++ b/include/l4/generic/tcb.h @@ -152,13 +152,6 @@ static inline void set_task_ids(struct ktcb *task, struct task_ids *ids) task->tgid = ids->tgid; } -#define THREAD_IDS_MAX 1024 -#define SPACE_IDS_MAX 1024 - - -extern struct id_pool *thread_id_pool; -extern struct id_pool *space_id_pool; - struct ktcb *tcb_find(l4id_t tid); void tcb_add(struct ktcb *tcb); void tcb_remove(struct ktcb *tcb); diff --git a/src/api/thread.c b/src/api/thread.c index 4ae29ba..ed776bb 100644 --- a/src/api/thread.c +++ b/src/api/thread.c @@ -226,13 +226,17 @@ int arch_setup_new_thread(struct ktcb *new, struct ktcb *orig, int thread_setup_new_ids(struct task_ids *ids, unsigned int flags, struct ktcb *new, struct ktcb *orig) { + ids->tid = new->tid; + /* * If thread space is new or copied, * thread gets same group id as its thread id */ if (flags == THREAD_NEW_SPACE || - flags == THREAD_COPY_SPACE) + flags == THREAD_COPY_SPACE) { ids->tgid = ids->tid; + new->tgid = new->tid; + } /* * If the tgid of original thread is supplied, that implies the @@ -240,11 +244,13 @@ int thread_setup_new_ids(struct task_ids *ids, unsigned int flags, * it is. Otherwise the thread gets the same group id as its * unique thread id. */ - if (flags == THREAD_SAME_SPACE && ids->tgid != orig->tgid) + if (flags == THREAD_SAME_SPACE && ids->tgid != orig->tgid) { ids->tgid = ids->tid; + new->tgid = new->tid; + } /* Set all ids */ - set_task_ids(new, ids); + //set_task_ids(new, ids); return 0; } @@ -296,11 +302,10 @@ out: int thread_create(struct task_ids *ids, unsigned int flags) { struct ktcb *new; - struct ktcb *parent; + struct ktcb *parent = 0; int err; flags &= THREAD_CREATE_MASK; - parent = 0; if (!(new = tcb_alloc_init())) return -ENOMEM; @@ -337,7 +342,7 @@ int thread_create(struct task_ids *ids, unsigned int flags) return 0; out_err: - /* Pre-mature tcb needs freeing by free_page */ + /* Pre-mature tcb needs freeing by free_ktcb */ free_ktcb(new); return err; } diff --git a/src/generic/tcb.c b/src/generic/tcb.c index 9f76a80..d593631 100644 --- a/src/generic/tcb.c +++ b/src/generic/tcb.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include INC_ARCH(exception.h) @@ -25,8 +26,6 @@ void init_ktcb_list(struct ktcb_list *ktcb_list) void tcb_init(struct ktcb *new) { - new->tid = id_new(&kernel_container.ktcb_ids); - new->tgid = new->tid; link_init(&new->task_list); mutex_init(&new->thread_control_lock); @@ -51,11 +50,19 @@ struct ktcb *tcb_alloc(void) struct ktcb *tcb_alloc_init(void) { struct ktcb *tcb; + struct task_ids ids; if (!(tcb = tcb_alloc())) return 0; + ids.tid = id_new(&kernel_container.ktcb_ids); + ids.tgid = L4_NILTHREAD; + ids.spid = L4_NILTHREAD; + + set_task_ids(tcb, &ids); + tcb_init(tcb); + return tcb; }