LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-21-2011, 06:03 AM   #1
sunil.d
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Rep: Reputation: Disabled
signal from kernel space to user space


Hi ,

I have the following requirement in my module.
The driver gets some data from the external device. After getting 1MB of data it has to send it to the user space application.

What is the best thing to implement for this in driver.?

Is it ok to implement like, after getting data, the driver will send a signal to the user space application. Then the user space application sends an ioctl to read the data.

Is there any alternate, that the driver directly sends the data without the user space application asks for it.? I dont think its feasible, but just asking if I missed something.

Thanks in advance.

Sunil.
 
Old 07-21-2011, 05:33 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
The usual way for something like this is a standard UNIX I/O call. User space starts everything in motion. For example it issues a read to your driver which passes in the address of a 1 MB memory buffer. The user space program is now sleeping waiting for the kernel to respond. The driver puts the data into the memory buffer and then completes the I/O. This wakes up the waiting user space program which now has its 1 MB of data.

Doing it the other way around as you propose has a number of problems. What if there are two user space programs? What if there are multiple devices? What if the user space program has stopped running? What if you get less than 1 MB? How do you tell user space if the device got an error? All of these are handled by the standard way of doing things, none of them are if you make up your own way.
 
Old 07-22-2011, 01:33 AM   #3
sunil.d
LQ Newbie
 
Registered: Jul 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Hi smallpond,
Thanks a lot for your feedback.

can you please brief me the i/o call you mentioned.
You mean I need to use read system call for this from user application or do I need
to use any ioctl.
Does the user application sleeps itself after initiating the read or we need to call any sleep function.
I dont know if it is very basic as I am not familiar with linux.

Please help me.

Regards,
Sunil.
 
Old 07-22-2011, 06:38 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
The user-space program(s) always need to "rendezvous" with the kernel-space through some kind of call which it makes. "ioctl()" or an asynchronous read is what is normally used.
 
Old 07-22-2011, 08:17 AM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Quote:
Originally Posted by sunil.d View Post
Hi smallpond,
can you please brief me the i/o call you mentioned.
You mean I need to use read system call for this from user application or do I need
to use any ioctl.
Does the user application sleeps itself after initiating the read or we need to call any sleep function.
I dont know if it is very basic as I am not familiar with linux.
This is not a Linux question, this is an Operating System question. Applications run in user space. The kernel provides services. This is true in all environments. Read "Linux Device Drivers" for a description of how the two communicate.
 
  


Reply



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
Free user space pages of different user processes from inside kernel space trueskyte Linux - Kernel 1 10-22-2010 04:37 PM
Division of Logical Memory Space in to User Space and Kernel Space shreshtha Linux - Newbie 2 01-14-2010 09:59 AM
Do we have any chance of calling user space callback function from kernel space? ravishankar.g Linux - Newbie 1 09-22-2009 07:14 PM
how to call socket prog code written in user space from kernel space???HELP kurt2 Programming 2 07-15-2009 09:56 PM

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

All times are GMT -5. The time now is 06:27 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