ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.