On 9/3/06, Ashok Sharma <aks6d@xxxxxxxxxxx> wrote:
Pl explain the following code segment that iterates over a process's children struct task_struct *task; struct list_head *list; list_for_each( list, ¤t->children) { task = list_entry (list, struct task_struct, sibling); } The doubt is in respective second arguments in the two functions. The code is from LKD2
The task struct's children points to the child of the task. All the siblings (tasks having same parent) is linked together by a linked list. both children and sibling are generic linked list type. task->children acts as a list head for the list of siblings. list_for_each() is a macro for for loop to iterate over a list. The task->children is used as a list head. list is updated on each loop. in second statement, list_entry is used to get the task_struct from list. The sibling is used as a linkage for all the child of parent. i hope it helps. -- --------------------------------------------------------------- regards Manish Regmi --------------------------------------------------------------- UNIX without a C Compiler is like eating Spaghetti with your mouth sewn shut. It just doesn't make sense. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/