View topic - Qnx interrupt

Qnx interrupt

For discussion of realtime and/or embedded programming.

Qnx interrupt

Postby djidji » Thu Dec 07, 2017 1:43 pm


I'm using QNX6.5 SP1, and try to make a driver for FlexCAN.

using this code to test my interrupt handler, Sometimes it work correctly (the program receive 10 interrupts and printf "itr receive : 10")
and the most of times, it nb_it jump with 200, don't increment correclty and blocks in InterruptWait(0,NULL) (I can see this with debugger), then the programm doesn't change in case future interrupts

I don't understand why 200 and why it does this, knowing that it can do it at any time of increment
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <sys/neutrino.h>
#include <string.h>
#include <sys/mman.h>
#include <hw/inout.h>
#include <stdint.h>

const struct sigevent *neutrino_handler(void *data, int id);
volatile uintptr_t ptr;
struct sigevent event;
int nb_it=0;

int main(void) {

int i;
int itr_ret;
   ThreadCtl(_NTO_TCTL_IO, 0);

   ptr= mmap_device_io(0x10,0x2090028);

   event.sigev_notify = SIGEV_INTR;

   itr_ret=InterruptAttach(142, neutrino_handler,
                            NULL, 0,
      printf("erreur attach\n");

for (i=0;i<10;i++)

   InterruptWait(0,NULL); // wait for interrupt

printf("itr received : %d\n",nb_it);
   return EXIT_SUCCESS;

const struct sigevent *
neutrino_handler(void *data, int id)
   InterruptDisable(); //   _disable();

   out32(ptr+8, 0x10); //clear interrupt


Active Member
Posts: 22
Joined: Tue Jun 28, 2016 1:17 pm

Re: Qnx interrupt

Postby Tim » Fri Dec 08, 2017 2:43 pm

I don't think you understand how interrupts work.

This call: InterruptWait(0,NULL) simply says your main program is going to loop 10 times waiting for an interrupt. It DOESN'T limit the interrupt handler to only process 10 interrupts.

Your interrupt handler is running in the kernel space and could be called any number of times between the time your program loops one time. How many times it gets called is entirely dependent on the external hardware that's causing the interrupt.

That's also why your program sometimes blocks and doesn't finish it's loop of 10 because the external hardware stopped triggering the interrupt.

Senior Member
Posts: 1522
Joined: Wed Mar 10, 2004 12:28 am

Re: Qnx interrupt

Postby maschoen » Fri Dec 22, 2017 4:08 am

Normally you should not be doing calling InterruptDisable() inside the interrupt handler.
QNX already causes prioritization, so only a higher priority interrupt will interrupt your handler.
QNX Master
Posts: 2731
Joined: Wed Jun 25, 2003 5:18 pm

Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 4 guests