Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add a peridic timer callback in a linux kernel module
    text
    copied!<p>I am working on a Linux kernel module that registers a callback for interrupts that come from a custom-made board and puts the received data in a queue behind a char device interface to be processed by an application. This module needs to constantly monitor and measure the interrupts and data that comes from the board even if no interrupt comes from the board, so it has another callback that triggers according to time.</p> <p>Current implementation uses RTC interrupt as a constant timer source. I disable kernel RTC drivers (<code>CONFIG_RTC_DRV_CMOS</code>) and request for IRQ 8 and hook the timer callback as RTC interrupt handler. Interrupts are generated every second from RTC chip.</p> <p>The problem is we have to lose some of Linux's ability to manage time in this way, because only one of <code>rtc-cmos</code> or the board module can be loaded at once (and obviously we've chosen the board module).</p> <p>Target architecture is i386 PC.</p> <p>I'm not a kernel developer and so don't have a big picture on kernel module development, but I'm trying to find my way and these are nearest thing to solution that come to my mind:</p> <ul> <li>Somehow share the IRQ 8 between both modules (maybe like <code>request_irq(8, rtc_handler, IRQF_SHARED, rtc_handler)</code>?) or chainload IRQ handlers.</li> <li>Finding another way to hook a handler from a kernel module to RTC interrupt, rather than registering for IRQ 8.</li> <li>Finding another source of 1-second timer events that can be used from within a kernel module, maybe there is a standard kernel API for that, I don't know.</li> </ul> <p>I suppose there might be a simple and standard way to do this and I would be glad If anyone would comment on either of these solutions or suggest others.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload