1

I have a Linux device driver which uses an interrupt handler to do its work.

How can I schedule the interrupt handler to be invoked every X milliseconds (the interrupt line is broken)?

Isaac Kleinman
  • 3,994
  • 3
  • 31
  • 35

1 Answers1

2

Assuming that you are only doing this for debugging purposes until you fix the interrupt line, you could try calling your ISR (minus its context saving code) inside timer_interrupt in arch/*/kernel/time.c before that code re-enables interrupts. You will have to add some code to make it fire only one out of Y ticks if you need a slower rate than the tick source.

If running the ISR in interrupt context is not your objective and you just want to get the bottom half driver code to run periodically you could use the timer API instead of hacking timer_interrupt. In this case your ISR code won't be executing in interrupt context.

If you need a faster rate than the tick source you will probably need to use a highres timer. Here again, you won't actually be executing in interrupt context.

There is a good introduction highres timers and the timer API by here. There is an example user space timer in the timer_create( ) man page. For kernel space timers you need hrtimer_init(), and hrtimer_start(). There is an example hrtimer here . To get this to work periodically I guess you would just reset the timer each time it fires or use the hrtimer_forward( ) solution in this SE post.

Community
  • 1
  • 1
Jonathan Ben-Avraham
  • 4,615
  • 2
  • 34
  • 37