Now that you've attached an interrupt

At this point, you've called either InterruptAttachEvent() or InterruptAttach().

Note: Since attaching an interrupt isn't something you want everyone to be able to do, Neutrino allows only threads that have "I/O privileges" enabled to do it (see the ThreadCtl() function in the QNX Neutrino C Library Reference). Only threads running from the root account, that are setuid() to root, or that have the PROCMGR_AID_IO ability enabled (see procmgr_ability()) can obtain "I/O privileges"; hence we're effectively limiting this ability to root. Unprivileged threads must also have the PROCMGR_AID_INTERRUPT ability enabled.

Here's a code snippet that attaches an ISR to the hardware interrupt vector, which we've identified in our code sample by the constant HW_SERIAL_IRQ:

#include <sys/neutrino.h>

int interruptID;

const struct sigevent *
intHandler (void *arg, int id)
{
    ...
}

int
main (int argc, char **argv)
{
    ...
    interruptID = InterruptAttach (HW_SERIAL_IRQ, 
                                   intHandler, 
                                   &event, 
                                   sizeof (event), 
                                   0);
    if (interruptID == -1) {
        fprintf (stderr, "%s:  can't attach to IRQ %d\n",  
                 progname, HW_SERIAL_IRQ);
        perror (NULL);
        exit (EXIT_FAILURE);
    }
    ...
    return (EXIT_SUCCESS);
}

This creates the association between the ISR (the routine called intHandler(); see below for details) and the hardware interrupt vector HW_SERIAL_IRQ.

At this point, if an interrupt occurs on that interrupt vector, our ISR will be dispatched. When we call InterruptAttach(), the kernel unmasks the interrupt source at the PIC level (unless it's already unmasked, which would be the case if multiple ISRs were sharing the same interrupt).