diff --git a/include/l4/generic/tcb.h b/include/l4/generic/tcb.h index 82fa4b3..37a77da 100644 --- a/include/l4/generic/tcb.h +++ b/include/l4/generic/tcb.h @@ -51,6 +51,7 @@ typedef struct arm_context { struct task_ids { l4id_t tid; l4id_t spid; + l4id_t tgid; }; struct ktcb { @@ -70,6 +71,7 @@ struct ktcb { /* Thread information */ l4id_t tid; /* Global thread id */ l4id_t spid; /* Global space id */ + l4id_t tgid; /* Global thread group id */ /* Flags to hint scheduler on future task state */ unsigned int schedfl; @@ -140,14 +142,17 @@ static inline void set_task_ids(struct ktcb *task, struct task_ids *ids) { task->tid = ids->tid; task->spid = ids->spid; + task->tgid = ids->tgid; } #define THREAD_IDS_MAX 1024 #define SPACE_IDS_MAX 1024 +#define TGROUP_IDS_MAX 1024 extern struct id_pool *thread_id_pool; extern struct id_pool *space_id_pool; +extern struct id_pool *tgroup_id_pool; #endif /* __TCB_H__ */ diff --git a/src/api/syscall.c b/src/api/syscall.c index b25df95..380259e 100644 --- a/src/api/syscall.c +++ b/src/api/syscall.c @@ -71,6 +71,8 @@ int sys_getid(syscall_context_t *regs) ids->tid = this->tid; ids->spid = this->spid; + ids->tgid = this->tgid; + return 0; } diff --git a/src/api/thread.c b/src/api/thread.c index e3e7192..6c75890 100644 --- a/src/api/thread.c +++ b/src/api/thread.c @@ -175,6 +175,12 @@ out: if ((ids->spid = id_get(space_id_pool, ids->spid)) < 0) ids->spid = id_new(space_id_pool); + + /* It also gets a thread group id */ + if ((ids->tgid = id_get(tgroup_id_pool, + ids->tgid)) < 0) + ids->tgid = id_new(tgroup_id_pool); + } /* Set all ids */ diff --git a/src/generic/tcb.c b/src/generic/tcb.c index cde6f72..fa4d2b5 100644 --- a/src/generic/tcb.c +++ b/src/generic/tcb.c @@ -10,6 +10,7 @@ /* ID pools for threads and spaces. */ struct id_pool *thread_id_pool; struct id_pool *space_id_pool; +struct id_pool *tgroup_id_pool; /* Hash table for all existing tasks */ struct list_head global_task_list; diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c index 4088a7d..045ff95 100644 --- a/src/glue/arm/init.c +++ b/src/glue/arm/init.c @@ -331,8 +331,10 @@ void init_tasks() /* Initialise thread and space id pools */ thread_id_pool = id_pool_new_init(THREAD_IDS_MAX); space_id_pool = id_pool_new_init(SPACE_IDS_MAX); + tgroup_id_pool = id_pool_new_init(TGROUP_IDS_MAX); ids.tid = id_new(thread_id_pool); ids.spid = id_new(space_id_pool); + ids.tgid = id_new(tgroup_id_pool); /* Initialise the global task list head */ INIT_LIST_HEAD(&global_task_list); diff --git a/tasks/libl4/include/l4lib/arch-arm/types.h b/tasks/libl4/include/l4lib/arch-arm/types.h index 8ead25a..c7a474a 100644 --- a/tasks/libl4/include/l4lib/arch-arm/types.h +++ b/tasks/libl4/include/l4lib/arch-arm/types.h @@ -5,6 +5,7 @@ struct task_ids { int tid; int spid; + int tgid; }; #include