Problem of workqueue
Hi, I want to use workqueue in my irq handler. Some materials say that I can use INIT_WORK( &work, function, &data ); to initialize work, whose type is struct work_struct, and data is something should be passed to function. however, it seems that now the macro INIT_WORK() only accept two parameters:&work and function. My problem is how to pass data to the function and why they change that macro? Thanks!
On May 3, 2012 8:37 PM, "夏业添" <summerxyt@gmail.com> wrote:
Hi,
I want to use workqueue in my irq handler. Some materials say that I can
use
INIT_WORK( &work, function, &data );
to initialize work, whose type is struct work_struct, and data is something should be passed to function. however, it seems that now the macro INIT_WORK() only accept two parameters:&work and function.
My problem is how to pass data to the function and why they change that
macro?
Thanks!
May be you are looking for something like this: http://www.linuxforums.org/forum/kernel/183688-init_work-two-arguments.html ~chetan _______________________________________________
Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi Chetan, Thanks for reply and it works. And I want to verify some other things. Is it a good way to use workqueue to do this job: send data to user space through netlink socket from kernel? Thanks! 2012/5/4 Chetan Nanda <chetannanda@gmail.com>:
On May 3, 2012 8:37 PM, "夏业添" <summerxyt@gmail.com> wrote:
Hi,
I want to use workqueue in my irq handler. Some materials say that I can use
INIT_WORK( &work, function, &data );
to initialize work, whose type is struct work_struct, and data is something should be passed to function. however, it seems that now the macro INIT_WORK() only accept two parameters:&work and function.
My problem is how to pass data to the function and why they change that macro?
Thanks!
May be you are looking for something like this: http://www.linuxforums.org/forum/kernel/183688-init_work-two-arguments.html
~chetan _______________________________________________
Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
On Fri, May 4, 2012 at 6:55 AM, 夏业添 <summerxyt@gmail.com> wrote:
Hi Chetan,
Thanks for reply and it works. And I want to verify some other things.
Is it a good way to use workqueue to do this job: send data to user space through netlink socket from kernel?
Thanks!
2012/5/4 Chetan Nanda <chetannanda@gmail.com>:
On May 3, 2012 8:37 PM, "夏业添" <summerxyt@gmail.com> wrote:
Hi,
I want to use workqueue in my irq handler. Some materials say that I can use
INIT_WORK( &work, function, &data );
to initialize work, whose type is struct work_struct, and data is something should be passed to function. however, it seems that now the macro INIT_WORK() only accept two parameters:&work and function.
My problem is how to pass data to the function and why they change that macro?
Thanks!
May be you are looking for something like this:
http://www.linuxforums.org/forum/kernel/183688-init_work-two-arguments.html
~chetan _______________________________________________
Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi, To send data from kernel space and user-space see kernel's notification mechanism like fanotify which works on by creating an anonymous fd in the user-space process's context which then might perform normal read() and write() call to receive and send data to kernel. - Rohan
Hi rohan, I google fanotify and find it's a notification mechanism. My understanding is that fanotify can know fd being open, close, read, write, but transfer data between user space and kernel is out of its ability. If I'm wrong please tell me. The only reason I choose netlink to send data to user space is to notify user space process there is data, and avoid user space process do some polling job to check if there is data in kernel. Does fanotify or other method can do such thing? Thanks a lot! 2012/5/4 rohan puri <rohan.puri15@gmail.com>:
Hi, To send data from kernel space and user-space see kernel's notification mechanism like fanotify which works on by creating an anonymous fd in the user-space process's context which then might perform normal read() and write() call to receive and send data to kernel.
- Rohan
On Fri, May 4, 2012 at 10:55 AM, 夏业添 <summerxyt@gmail.com> wrote:
Hi rohan,
I google fanotify and find it's a notification mechanism. My understanding is that fanotify can know fd being open, close, read, write, but transfer data between user space and kernel is out of its ability. If I'm wrong please tell me.
The only reason I choose netlink to send data to user space is to notify user space process there is data, and avoid user space process do some polling job to check if there is data in kernel. Does fanotify or other method can do such thing?
Thanks a lot!
2012/5/4 rohan puri <rohan.puri15@gmail.com>:
Hi, To send data from kernel space and user-space see kernel's notification mechanism like fanotify which works on by creating an anonymous fd in the user-space process's context which then might perform normal read() and write() call to receive and send data to kernel.
- Rohan
To notify itself requires some data transfer. You can easily implement your own mechanism similar to fanotify which would contain you_fops (file operations) from which you could transfer data. Yes, user process needs to do polling to check whether data is available on the fd or not. - Rohan
participants (3)
-
Chetan Nanda -
rohan puri -
夏业添