Re: Process Family Tree code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks.

However,

list_for_each( list, &current->children) {

 task = list_entry (list, struct task_struct, sibling);
}

is another macro where current is pointer type then why &current->children (is & before current correct)

Cheers
Ashok





Manish Regmi <regmi.manish@xxxxxxxxx>
wrote:
On 9/3/06, Ashok Sharma 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, &current->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.


Yahoo! Photos ? NEW, now offering a quality print service from just 7p a photo.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux