InterruptAttachEvent() only once a time

Hi Community !!!

why this code witch InterruptAttachEvent() works only just once a time and not quite often???

[color=green]#include <stdio.h>
#include <stdlib.h> /* for EXIT_* /
#include <stdint.h> /
for uintptr_t /
#include <sys/neutrino.h> /
for ThreadCtl() */

define IRQ 0

int
main( void )
{
int privity_err;

struct sigevent event;
int intr_id;
int i;

/* Give this thread root permissions to access the hardware */
privity_err = ThreadCtl( _NTO_TCTL_IO, NULL );
if ( privity_err == -1 )
{
	printf( "Can't get root permissions\n" );
	return -1;
}

/* Tell the kernel to attach an interrupt signal event to this thread */
event.sigev_notify = SIGEV_INTR;
intr_id = InterruptAttachEvent( IRQ, &event, 0 );
if ( intr_id == -1 )
{
	printf( "Couldn't attach event to IRQ %d\n", Timer IRQ );
	return EXIT_FAILURE;
}

for ( i = 0; i < 10; i++ )
{
	/* Sleep until the next interrupt */
	InterruptWait( 0, NULL );
	printf("Interrupt \n");
    /* Reenable this interrupt */
	InterruptUnmask( IRQ, intr_id );
}

/* Remove the attachment from this thread */
InterruptDetach( intr_id );

return EXIT_SUCCESS;

}

Thank you !!!

Since you thread is not reponsible for clearning the interrupt signal itself, i don’t think it should use InterruptUnmask()

Thank you mario

No this is not the problem If I don’t use InterruptUnmask() nothing works.

qnx.com/developers/docs/mome … event.html
means:

To prevent infinite interrupt recursion, the kernel automatically does an InterruptMask() for intr when delivering the event. After the interrupt-handling thread has dealt with the event, it must call InterruptUnmask() to reenable the interrupt.

Always pass the _NTO_INTR_FLAGS_TRK_MSK flag to InterruptAttachEvent().

Yeah!!!

great now it works

_NTO_INTR_FLAGS_TRK_MSK

Thank you !!!