eduardosufan
eduardosufan

Reputation: 1582

How to transmit data from an interrupt handler to an user application?

A device that produces an interrupt is managed by a handler in the kernel. I need to send a message with a flag, so that the user application receives the notification of an interruption has occurred, and thus can perform a procedure. For example, wake up a process. How do I do this?

Upvotes: 4

Views: 2345

Answers (2)

srd
srd

Reputation: 1267

I prefer to use Netlink as an IPC between kernel and user-space. Just make sure to allocate the message using GFP_ATOMIC (in netlink_broadcast) to make sure you don't sleep in the irq. Have a look here for an Netlink tutorial.

Upvotes: 2

M.E.L.
M.E.L.

Reputation: 613

IMHO the POSIX style solution would be to write a device driver that receives the interrupts in the kernel. The user space program would open a device file and icoctl() or read() from it, blocking until at least one event had arrived. I suggest, that the user space program should actually read a bit more:

  • How many events have arrived so far?)
  • Has the call blocked (e.g. there were no events queued when reading from the device)

This would help you, to see when your program is misisng events (e.g. because it has ben deleayed in the previous cycle).

Upvotes: 2

Related Questions