2
votes

Where can i find the definition of the "struct list_head children; /* list of my children */" which is used in sched.h to keep the children of a process?
I need to access the task_struct for a specific child but i don't know how to get a pointer to that and i don't know what the fields of the list of children are...
Thank you i advance.

1
We leave this as an exercise for the reader, it's one of the joys of hacking the kernel.KevinDTimm
Ok thanks for the answer.Any hint on this?For the current process and its parent process i know how to find the task_struct,but i have no idea of how to access the task struct for its children and its siblings.And i have no idea because they are stored in a list for which i don't even know what it contains.Thank you.Spyros
If you look in include/linux it will be quite apparent where list_head is defined :)KevinDTimm
Ok.I think i just found it,located in list.h.It is defined as a doubly linked list and contains two pointers next and prev.But this does not help me,because with these pointers i can iterate through that list but i can't find a way to access its task_struct.Any suggestion on this?Thanks again.;)Spyros

1 Answers

2
votes

I think i found the solution with a little research on the net.I post it for anyone interested on this.

struct task_struct *task;
struct list_head *list;

list_for_each(list, &current->children) {
task = list_entry(list, struct task_struct, children); /* task now points to one of current's children */
}