33513

How does Linux kernel interrupt the application?

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,

Answer1:

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.

Answer2:

Typically, the kernel never notifies an application unless the application requests the notification and is waiting for the notification. On unix systems, this will typically be done using the select or similar routines. One supplies select with a set of file descriptors and select will then wait until there is activity on one of the file descriptors at which time it returns.

Given that on unix all devices are files, you should be able to make use of this mechanism to wake an application when an interrupt comes in on some hardware device.

Answer3:

There are plenty of kernel-userspace communication interfaces in addition to ioctl (signals, sockets, etc). Please, refer to Kernel Space - User Space Interfaces tutorial for detailed explanation.

Recommend

  • Windows authentication hybrid
  • How to join a thread in Linux kernel?
  • PHP download entire folder (recursive) via FTP
  • How does Android VpnService protect fd work?
  • Jasmine 2.0 async beforeEach not waiting for async to finish
  • MS Access 2010: Adding transaction management into a form
  • Is it expensive to create the Thread object or to actually start the thread?
  • How do I prepend to a stream in Bash?
  • Cross platform UI spacing/padding
  • Javascript/Jquery runs fast in desktop browsers, but slow in mobile/smartphone browsers…should I spl
  • How can I replace the server in Web Component Tester
  • Django model inheritance, filtering models
  • Ember.js model to be organised as a tree structure
  • converting text file into xml using php?
  • Diff between two dataframes in pandas
  • Tamper-proof configuration files in .NET?
  • Unable to get column index with table.getColumn method using custom table Model
  • custom UITableViewCell with image for highlighting
  • Create DicomImage from scratch using Dcmtk
  • Do I need to reset a Perl hash index?
  • Use of this Javascript
  • How to do unit test for HttpContext.Current.Server.MapPath
  • Splitting given String into two variables - php
  • How to get a value (ex: baseURL) in every Karate feature?
  • Validaiting emails with Net.Mail MailAddress
  • Javascript + PHP Encryption with pidCrypt
  • Display Images one by one with next and previous functionality
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • WOWZA + RTMP + HTML5 Playback?
  • 0x202A in filename: Why?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • Load html files in TinyMce
  • How do you join a server to an Active Directory (domain)?
  • Change div Background jquery
  • Busy indicator not showing up in wpf window [duplicate]
  • git trying to push non-existent file … after clearing cache
  • Why do underscore prefixed variables exist?