LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-15-2014, 01:47 AM   #1
akv1412
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Rep: Reputation: Disabled
How linux driver notify asynchrnous events to user space


Hi All,

I am looking methods to implements asynchronous events handing in kernel & send data to userspace.
I saw there are many ways to handle asynchrnous event in linux eg. fasync, poll etc.
My requirement is as soon as receive the event in kernel space, send event notification along with the data to user space.

Can any one send the best mechanism/ sample code use in linux?

Regards,
akv

Last edited by onebuck; 01-16-2014 at 05:25 AM. Reason: correct subject title
 
Old 01-15-2014, 04:59 AM   #2
prabhuraj
LQ Newbie
 
Registered: Aug 2011
Posts: 26

Rep: Reputation: Disabled
Hi,
The following link provides a snippet of code that may help you get started. Have a look.
http://www.compsoc.man.ac.uk/~moz/ke...s/asyncio.html
 
Old 01-15-2014, 11:12 AM   #3
akv1412
LQ Newbie
 
Registered: Jan 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks.

I use fasync asynchronous method and getting the event in user space.

In kernel, when kill_fasync(&fasync_my_queue, SIGIO, POLL_IN) invoke, receiving SIGIO (29) event in user space.

Is it possible to change SIGIO to some other value? so that I can differentiate events in user space.

Regards,
akv

Last edited by akv1412; 01-15-2014 at 11:15 AM.
 
Old 01-15-2014, 06:02 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
As far as I am aware ... no.

The purpose of any such signal, if you want to think of it this way, is merely "to wake the process up, if it is asleep," and to notify it (asynchronously ...) that it might have something to do. The signal is not associated with any particular request, and it might in fact turn out to be a false alarm.

The timing of such things is entirely fluid: the signal itself is nothing more and nothing less than a ringing bell that will wake-up a sleeping process and (whether or not it was sleeping ...) send it into a subroutine.

The user-land process, having been thusly informed that it might have work-to-do, must now issue whatever system calls may be required to find out if it (still) has work-to-do, and to do that work. It's entirely possible that said process may discover that, in any particular cycle, it has none. (Waking up a process "too often" is not a concern: "sorry to have bothered you." For the process to "go to sleep when still it has work to do," is.)

And this is pretty much the way that it is with every operating-system on the planet.

Last edited by sundialsvcs; 01-15-2014 at 06:06 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Steam Linux User Group Events For March LXer Syndicated Linux News 0 02-27-2013 01:31 AM
How the Linux device driver can inform the applications when some events occurs haribabu1836 Linux - Software 3 12-05-2011 06:32 AM
How to notify user about rebooting? KFC123 Linux - Newbie 5 08-19-2009 05:50 AM
Information about Disk sapce in linux lieuquocdat Linux - Newbie 2 07-05-2006 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:41 PM.

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