Re: About how to access a queue in a data-struct

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

 



On Sunday 18 July 2004 15:25, Heap Ho Tan wrote:
> Hi,
> I have the following code:
> I wanted to access the queue in the struct eventDest
> after adding it into a list. However, I just can't do
> it using this line of piece, how would I do it
> actually:
> tmp_2 = list_entry(tmp, struct eventDest, queue);
> **************************************
> LIST_HEAD(event_list);
>
> struct eventDest{
>   //Single lock for the whole data-structure
>   spinlock_t eventLock;
>   int eventID;
>   //declare a task list
>   int nb_process;
>   wait_queue_head_t queue;

    // if you are going to do a list_add() you'll
    // need a struct list_head
    struct list_head list;
> };
>
> struct eventDest *event;
>
> event=(struct eventDest *)kmalloc(sizeof(*event));
>
>  list_add( &event_list, event);
   // replace with
   list_add(&event->list, &event_list);
>
>  list_for_each( tmp, &event_list){
>     id = list_entry(tmp, struct eventDest, eventID);

      // You are using list_entry() wrong, try this..
      struct eventDest *e, *e2;
      e = list_entry(tmp, struct eventDest, queue);
      id = e->eventID;

>     if( id == tmpID ){
>       tmp_2 = list_entry(tmp, struct eventDest, queue);

        // try this
        e2 = list_entry(tmp, struct eventDest, list);
        tmp_2 = e->queue;

>       sleep_on(tmp_2);
>     }
>     printk("%d\n", id);
>   }


--
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