Re: How to post a message to a kernel thread

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

 



Hello,

I have another doubt here. When i do a spin_lock_bh and then after taking that lock if a sock_alloc_skb call is issued, the alloc buf fails. In the function sock_alloc_skb(), there is a check for
in_interrupt(). After acquiring a spin_lock_bh the in_interrupt is returning true and the alloc_skb fails

 
In that case even if i create a new kernel thread and share the linked list between ppp module and kernel thread and if i use the spin_lock to protect my list. It again will fail inside the sock_sendmsg function(because of the sock_alloc_skb function) if i try to use the same buffer received by ppp module. Since this is in the data path, in the new kernel thread i dont want to make a copy of the buffer i want to pass the same buffer

Isnt the spinlock similar to the semaphores what we normally use in other RTOS..??

Thanks and Regards,
Vanitha



>     Thanks for your mail. I basically want to send the packets
>     received by the synchronous ppp tty module (ppp_synctty.c)
>     to a socket application. Since the ppp transmit function is called
>     from interrupt context, i am not able to invoke the sock_sendmsg
>     call.
>
i don't know much about the ppp core, so i assume the above statement is 
correct

>     So i thought of creating a new kernel thread which will have a queue
>     so that from the sync ppp tty module i will post the packets to this
>     queue. From this kernel thread i can write the message to the 
>     socket.
>  
>
well looks like all you need is a static data structure like: buffer / 
linked list. They both need
to be protected by a spinlock (due to the interrupt context issues).

My idea is:
the kernel_thread goes to sleep (in a wait queue) waiting for a packet.
When a packet is received from the ppp core you enqueue it in the 
choosen data structre (buffer/linked list), and wake the kernel_thread.

If you're working against the 2.6, take a look at the workqueue ... 
maybe you
can simplify your code by using on of such queue.

Hope these helps.






_____________________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now! Visit http://www.TechEmail.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