Re: question about include/linux/list.h

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

 



Hi,
   As you stated below I saw SET_LINKS in sched.h file
and everything makes sense. I did not know that the
parents processes children member points to the childs
sibling member. I thought it pointed to the children
member of the child and that is where I went wrong.

Thanks
Vish

--- Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote:

> Hello.....
> 
> > From what I understand, list_for_each above will
> > iterate through one of the current processes child
> (if
> > there was one), then that childs child(if there is
> > one) and so on. Am I right in concluding this?
> This
> > means only the first iteration will find the
> current
> > processes child.
> 
> No. The codes you read are simply iterating on all
> children of a certain 
> task. So, if process A is forking process B,C and D,
> the snippets will 
> iterate from B to D, but not the children of B, C or
> D :)
> 
> > linux/kernel.h, task cannot point to the
> task_struct
> > of the child because  list_entry subtracts the
> offset
> > of sibling member from the address of the children
> > member. This will subtract more than is necessary.
> So,
> > the first argument of list_entry should point to a
> > list head member with the same member name within
> the
> > struct. Otherwise it will not return the address
> of
> > the containing struct. Am I right in concluding
> this?
> 
> I don't understand your question clearly, but I
> assume that you have 
> doubt about whether is it correct to use "list" as
> first argument for 
> list_entry(), am I correct?
> 
> recall the fact that "list" is actually a pointer
> pointing to each node 
> of current->children's linked list. "list" itself
> won't give any clue 
> because it can be anything which is declared as
> list_head.
> 
>  that's why you need third argument, that is
> "sibling". Since "sibling" 
> is the pointer which points to the parent's
> children, this is the one 
> you need. In other word, "sibling" is the list_head
> you are looking 
> for.
> 
> For better insight why it works, see copy_process()
> on kernel/fork.c and 
> pay attention when it calls SET_LINKS (see
> include/linux/sched.h). 
> 
> > From what I understand browsing through the kernel
> > source, the only way to iterate through a
> processes
> > children is by asking a child to iterate through
> its
> > siblings. Am I right?
> 
> IIRC, that is another solution you can pick.
> 
> regards
> 
> Mulyadi
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[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