D Programming/RTAI/User Space Interrupts

From Wikibooks, open books for an open world
Jump to: navigation, search

RTAI has user space interrupts called RTAI USI.

Let Linux assign a IRQ number for you PCI device[edit]

But before one can use them, the hardware interrupt has to be mapped to interrupt in Linux. Therefore it is necessary to build a kernel module for the pci device, that registers the interrupt. With this action, the device gets a new interrupt number, which can be used in the usi.

Writing an interrupt handler[edit]

Create a realtime thread:

In the thread make a loop, looking like that:

public void run(){
  const int irqNum = 5;
  rt_request_irq_task( irqNum, null, RT_IRQ_TASK, 1 );
  rt_startup_irq( irqNum );
  rt_enable_irq( irqNum );
  while( true ){
    int overrun = rt_irq_wait( irqNum );
    if( overrun == RT_IRQ_TASK_ERR )
    // if program should quit, break here
    // Do the irq handling
  rt_release_irq_task( irqNum );