Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 8

InterruptAttachEvent(), InterruptAttachEvent_r()

Attach an event to an interrupt source

Synopsis:

#include <sys/neutrino.h>

int InterruptAttachEvent( 
       int intr,
       const struct sigevent* event,
       unsigned flags );

int InterruptAttachEvent_r( 
       int intr,
       const struct sigevent* event,
       unsigned flags );

Arguments:

intr
The interrupt vector number that you want to attach an event to; for more information, see Interrupt vector numbers in the documentation for InterruptAttach().
event
A pointer to the sigevent structure that you want to be delivered when this interrupt occurs.
flags
Flags that specify how you want to attach the interrupt handler. For more information, see Flags,” below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The InterruptAttachEvent() and InterruptAttachEvent_r() kernel calls attach the given event to the hardware interrupt specified by intr. They automatically enable (i.e unmask) the interrupt level.

The InterruptAttachEvent() and InterruptAttachEvent_r() functions are identical except in the way they indicate errors. See the Returns section for details.

Before calling either of these functions, the thread must request I/O privileges by calling:

 
ThreadCtl( _NTO_TCTL_IO, 0 );

If the thread doesn't do this, it might SIGSEGV when it calls InterruptAttachEvent() or InterruptAttachEvent_r().

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.

Consider the following when choosing an event type:

On a multicore system, the thread that receives the event set up by InterruptAttachEvent() runs on any CPU, limited only by the scheduler and the runmask.

Flags

The flags argument is a bitwise OR of the following values, or 0:

Flag Description
_NTO_INTR_FLAGS_END Put the new event at the end of the list of existing events instead of the start.
_NTO_INTR_FLAGS_PROCESS Associate the event with the process instead of the attaching thread.
_NTO_INTR_FLAGS_TRK_MSK Track calls to InterruptMask() and InterruptUnmask() to make detaching the interrupt handler safer.

_NTO_INTR_FLAGS_END

The interrupt structure allows hardware interrupts to be shared. For example if two processes call InterruptAttachEvent() for the same physical interrupt, both events are sent consecutively. When an event attaches, it's placed in front of any existing events for that interrupt and is delivered first. You can change this behavior by setting the _NTO_INTR_FLAGS_END flag in the flags argument. This adds the event at the end of any existing events.

_NTO_INTR_FLAGS_PROCESS

Adding _NTO_INTR_FLAGS_PROCESS to flags associates the interrupt event with the process instead of the attaching thread. The interrupt event is removed when the process exits, instead of when the attaching thread exits.


Note: The kernel automatically attempts to set the _NTO_INTR_FLAGS_PROCESS flag if the event is directed at the process in general (for SIGEV_SIGNAL, SIGEV_SIGNAL_CODE, and SIGEV_PULSE events).

_NTO_INTR_FLAGS_TRK_MSK

The _NTO_INTR_FLAGS_TRK_MSK flag and the id argument to InterruptMask() and InterruptUnmask() let the kernel track the number of times a particular interrupt handler or event has been masked. Then, when an application detaches from the interrupt, the kernel can perform the proper number of unmasks to ensure that the interrupt functions normally. This is important for shared interrupt levels.


Note: You should always set _NTO_INTR_FLAGS_TRK_MSK.

Advantages & disadvantages

InterruptAttachEvent() has several advantages over InterruptAttach():

There are also some disadvantages:

You can freely mix calls to InterruptAttach() and InterruptAttachEvent() for a particular interrupt.

Blocking states

This call doesn't block.

Returns:

The only difference between these functions is the way they indicate errors:

InterruptAttachEvent()
An interrupt function ID. If an error occurs, -1 is returned and errno is set.
InterruptAttachEvent_r()
An interrupt function ID. This function does NOT set errno. If an error occurs, the negative of a value from the Errors section is returned.

Use the ID with InterruptDetach() to detach this interrupt event.

Errors:

EAGAIN
All kernel interrupt entries are in use.
EFAULT
A fault occurred when the kernel tried to access the buffers provided.
EINVAL
The value of intr isn't a valid interrupt number.
EPERM
The process doesn't have I/O privileges.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

InterruptAttach(), InterruptDetach(), InterruptLock(), InterruptMask(), InterruptUnlock(), InterruptUnmask(), InterruptWait(), sigevent

Writing an Interrupt Handler chapter of the Neutrino Programmer's Guide

Interrupts chapter of Getting Started with QNX Neutrino


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 427

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/i/interruptattachevent.html on line 427