Construct your driver so that the process has a thread blocking on suitable syscall (read()
, ioctl()
) with the ISR waking up that thread (because at least one byte became available for read()
).
Then, make sure that thread has the highest priority possible, and preferably uses a realtime scheduler (SCHED_FIFO
or SCHED_RR
). In practice, if your process does not run with root privileges, you'll need to start the service with root privileges, setup the thread, then drop privileges; or give the binary executable CAP_SYS_NICE
capability via e.g. setcap pe=CAP_SYS_NICE binary
.
It is technically possible for the driver to also mess with the scheduling, but I would not do that. Anything that is so time-critical, should be done in the kernel ISR instead.
If you want to do it in userspace, because you don't want your code to be a derivative of the kernel and therefore GPL-licensed, you're on your own.