Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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 know that signal and fasync can be used between kernel and user mode, but it is not satisfied to be used in communication of kernel and user applications with multi-threading and processes. I would like to use message mechanism for communication between kernel and user mode, but I know IPC can not be used in kernel. Does anyone know any other alternative to user message communication between kernel device driver and user mode?
//--- ignored header you should know by yourself ---
#define DEV "/dev/XXXX"
int main (int argc ,char **argv)
{
int dev;
int cmd;
dev = open (DEV ,O_RDWR);
if (dev < 0) {
printf ("Can't open device\n");
return -1;
}
if ( argc == 2 ){
cmd = atoi( argv[1] );
} else{
cmd = 2;
}
write (dev, &cmd, sizeof(int) );
sleep (3);
close (dev);
return 0;
}
Thanks for your response. But that just for user access kernel device driver. I actually want to find a way for kernel initiates a message to a specific user application or user thread when kernel receives an interrupt. Any luck for that solution?
"When the kernel receives an interrupt" is probably a bit too hasty. There are an awful lot of those...
The kernel can easily issue a signal to a running process, and this might well be the easiest way to handle any sort of asynchronous notification.
You can also have the user application open a virtual-device, and when you need to tell the user process something, just write to the device. udev does that...
I don't know what your exact requirements are. But you could always use AIO (async I/O) which allows you to register callback functions for async notifications of I/O requests.
Check this: http://lse.sourceforge.net/io/aio.html
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.