Re: Use of list_head struct

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

 



Bogdan PRICOP
----------------------------------------
Mobile: +353 86 075 3349
E-mail: pricopb@xxxxxxxxx
----------------------------------------

On 17 June 2016 at 11:35, Pranay Srivastava <pranjas@xxxxxxxxx> wrote:
>
> On Fri, Jun 17, 2016 at 3:41 PM, Martin Houry <martinhoury@xxxxxxxxx> wrote:
> > Hello mailing list!
> > I've read some code in the NFS4.1 client. I have trouble to access
> > variables in a list_head.
> >
> > So I have :
> > (include/linux/sunrpc/xprt.h line 168)
> > struct rpc_xprt{
> >     .
> >     .
> >
> >     struct rpc_wait_queue pending; /* requests in flight */
> >     .
> >     .
> > }
> >
> > ==>
> >
> > struct rpc_wait_queue {
> >     .
> >     struct list_head        tasks[RPC_NR_PRIORITY]; /* task queue for
> > each priority level */
> >     .
> > }
> >
> > The struct "list_head" is a classical  linked list. But How do I know
> > the type of the struct in this list?
> > I can maybe guess the struct in it :
> >
> > struct rpc_task {}
> >
> > But how can I be certain that "struct list_head tasks" contains some
> > "struct rpc_task"?
>
> some magic value perhaps?
>
> >
> > I'm new here, thank you for your help!
> > Martin
> >

Hi Martin,

I think the main idea behind Linux kernel implementation of the linked
list (struct list_head) is to work with any kind of items which need
to be linked.

Please have a look at the below links which explain the internals of
Linux kernel list and its usage:
https://isis.poly.edu/kulesh/stuff/src/klist/
http://www.makelinux.net/ldd3/chp-11-sect-5

Thanks,
Bogdan

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[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