Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Usage of InterruptUnmask() within an interrupt handler: (1 Item)
   
Usage of InterruptUnmask() within an interrupt handler  
Hi:

I've been playing around with interrupt handlers on a PPC405EP processor running QNX6.3.2. I noticed that if I call 
InterruptUnmask() within my interrupt handler, the processor hangs and then eventually watchdog resets. Here is the code
 in my interrupt handler:

static volatile unsigned long count = 0;
static const struct sigevent* isr_handler (void* arg, int id)
{
    int rc = InterruptMask(IRQ4, id);
    count++;

    // NOTE: Can't call InterruptMask here or else it crashes for some reason
     rc = InterruptUnmask(IRQ4, id);

    return NULL;
}

Now if I create a helper thread for the interrupt:

static void* int_thread (void* arg)
{

   ...

    while (1)
    {
        InterruptWait(0, NULL);

        // Do something useful

        SIGEV_INTR_INIT( &(isrMsg.event) );
        InterruptUnmask(IRQ4, interrupt_id);
    }
}
 

and modify the isr_handler() to now signal the thread: 

static const struct sigevent* isr_handler (void* arg, int id)
{
    struct isr_msg* isrMsg = (struct isr_msg*) arg;
    struct sigevent* event = &(isrMsg->event);

    int rc = InterruptMask(IRQ4, id);
    count++;

    // NOTE: Can't call InterruptMask here or else it crashes for some reason
    // rc = InterruptUnmask(IRQ4, id);

   isrMsg->data = count;
    return event;
}

The call to InterruptUnmask() from the thread context does not hang the system. So any idea why the call to 
InterruptUnmask() from within the interrupt handler causes the system to hang ? The docs seem to indicate that it is 
'safe' to call from within an ISR. 

thanks
robert