LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-03-2005, 06:35 AM   #1
yhus
Member
 
Registered: May 2004
Posts: 75

Rep: Reputation: 15
callback or notification from kernel to user space


Hello,

I am working on a device driver. It is no problem to access driver from user space to call ioctl, read and write. But how can I issue a callback from kernel to user application? For example, my driver in kernel space receives some packets from hardware and need to pass the data to the application in user space, is it possible to pass a callback function from user space to kernel, so that the kernel can call the callback function in user space? Or using other mechanism to let kernel notifies user applicaitons asynchronously?

Thank you.
 
Old 09-04-2005, 11:58 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It is doable, but would make a big mess. Especially when the code crashes. It's much better idea to pass it to user space program to process. You can send a signal. It's a quite good solution if the signals are rather rare. How often you need to pass the packets?
 
Old 09-05-2005, 12:07 AM   #3
yhus
Member
 
Registered: May 2004
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks for your response. Signal is one of options, but the callback would be more appropriate for my driver. Could you please give more details for callback mechanism, or point me a resource for further reading?

Thank you.

Kind regards.

Last edited by yhus; 09-05-2005 at 06:00 PM.
 
Old 09-06-2005, 04:36 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Callback is done by just passing (as parameter, you can use casting if you don't have a good place for it) a function pointer (known propotype). Note that it's a great security risk (the function may do really nasty things).
 
Old 09-06-2005, 06:02 PM   #5
yhus
Member
 
Registered: May 2004
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks for your explanation. You are right, it is not safe. I am just thinking about to use IPC to send a message from the kernel space to the applications. Can the sys_msgsnd() be used in kernel space?

Thank you.

Kind Regards.

Last edited by yhus; 09-07-2005 at 06:38 AM.
 
Old 09-18-2005, 09:41 PM   #6
sbharsha
LQ Newbie
 
Registered: Sep 2005
Posts: 2

Rep: Reputation: 0
how to send signal from kernel

Hi,

I am also stuck here.

i don't know how send the signal from kernel space to user.

Please can u explain. or just give sample code if u have i will check it out..


Thanks
Please help me

harsha
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
notify user space application from the kernel space lordofring Linux - Software 2 06-22-2009 12:32 PM
user space daemons, kernel patches, modules ajitkth Linux - General 0 02-21-2005 08:01 AM
E-mail notification of low disk space Hypocrite Linux - General 2 11-10-2004 02:27 PM
User/Kernel Space Comms under Redhat 9.0 snigglyfox Programming 3 09-07-2004 05:24 AM
User Space - Kernel Space basu_arani Programming 3 05-25-2004 11:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration