Qnx interrupt


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]#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);

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

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




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.


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.