[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] kern: track the parent of a task
From: |
Justus Winter |
Subject: |
[PATCH 1/2] kern: track the parent of a task |
Date: |
Thu, 5 Sep 2013 16:57:42 +0200 |
Align Machs model of a task more closely with that of a Unix process
by tracking the parent task.
XXX: Not sure if it's worth keeping a real reference to the parent
since that way we prevent the parent task from being collected if it
dies before the child does.
* kern/task.h (struct task): Add field parent_task.
* kern/task.c (task_create): Keep a reference to the parent task.
(task_deallocate): Dereference the parent task.
---
kern/task.c | 3 +++
kern/task.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/kern/task.c b/kern/task.c
index 114dd31..0c0be99 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -105,6 +105,8 @@ kern_return_t task_create(
simple_lock_init(&new_task->lock);
queue_init(&new_task->thread_list);
new_task->suspend_count = 0;
+ task_reference(parent_task);
+ new_task->parent_task = parent_task;
new_task->active = TRUE;
new_task->user_stop_count = 0;
new_task->thread_count = 0;
@@ -206,6 +208,7 @@ void task_deallocate(
pset_deallocate(pset);
vm_map_deallocate(task->map);
is_release(task->itk_space);
+ task_deallocate(task->parent_task);
kmem_cache_free(&task_cache, (vm_offset_t) task);
}
diff --git a/kern/task.h b/kern/task.h
index 9bfea57..c8d9f3d 100644
--- a/kern/task.h
+++ b/kern/task.h
@@ -58,6 +58,7 @@ struct task {
vm_map_t map; /* Address space description */
queue_chain_t pset_tasks; /* list of tasks assigned to pset */
int suspend_count; /* Internal scheduling only */
+ task_t parent_task; /* Parent of the task */
/* Thread information */
queue_head_t thread_list; /* list of threads */
--
1.7.10.4
- Hacking gnumach to track parental relationship of tasks, Justus Winter, 2013/09/05
- [PATCH 1/2] kern: track the parent of a task,
Justus Winter <=
- [PATCH 2/2] kern: make the parent of a task available via task_info, Justus Winter, 2013/09/05
- Re: Hacking gnumach to track parental relationship of tasks, Ludovic Courtès, 2013/09/05
- Re: Hacking gnumach to track parental relationship of tasks, Justus Winter, 2013/09/06
- Re: Hacking gnumach to track parental relationship of tasks, Ludovic Courtès, 2013/09/06
- Re: Hacking gnumach to track parental relationship of tasks, Justus Winter, 2013/09/06
- Re: Hacking gnumach to track parental relationship of tasks, Ludovic Courtès, 2013/09/07
- Re: Hacking gnumach to track parental relationship of tasks, Justus Winter, 2013/09/07
- Re: Hacking gnumach to track parental relationship of tasks, Ludovic Courtès, 2013/09/07
- Re: Hacking gnumach to track parental relationship of tasks, Samuel Thibault, 2013/09/09
- Re: Hacking gnumach to track parental relationship of tasks, Ludovic Courtès, 2013/09/09