Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Linux kernel interrupt the application?

Tags:

c

linux-kernel

First of all, I am a device driver guy. This is my first time to handle an user mode program. I used to have an interrupt service routine to response a hardware interrupt. In other word, the hardware uses interrupt service routine to notify the driver to service. I use ioctl to be a channel to communicate between the application and device driver now and poll it to wait the response. Are there other ways that a device driver can notify an application when it finishes some task? Any comments are welcome. Thanks,

like image 650
codexplorer Avatar asked Jun 21 '26 05:06

codexplorer


1 Answers

There are several mechanisms for this. First approach: user-space application makes poll() or select() system call, waiting for some event from kernel. Second approach is to use Netlink sockets. There are also others like mmap() or signals. Google by kernel user-space IPC and you will see the whole list.

As for your case (drivers development), I'd say go with next approach. Create sysfs file in your driver, and do sysfs_notify() (and maybe wait_for_completion_interruptible_timeout() or something like that). In user-space do select() system call for your driver sysfs file. See how line discipline installed from user-space for example.

like image 146
Sam Protsenko Avatar answered Jun 22 '26 19:06

Sam Protsenko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!