op_intrpt_type_register()
Abstract
Registers a process as the direct recipient of all future interrupts of a particular type that arrive at the currently executing module. This replaces the default behavior which is to interrupt the module’s root process.
Syntax
op_intrpt_type_register (intrpt_type, pro_handle)
| Argument | Type | Description |
|---|---|---|
intrpt_type |
int |
type of interrupt for which registration is to be activated. Interrupt types are identified by the symbolic constants listed in Table 59 “Interrupt Type Symbolic Constants“ on page 15. Certain interrupt types cannot be used for this argument (see Details section). |
pro_handle |
Prohandle |
Handle for process designated as the direct recipient of interrupts of the specified type. This must be the handle of a valid (existing an local) process. |
Return Type
void
no return value
Example
/* Set up handler processes for special events in order to */
/* avoid having checks for these conditions throughout the */
/* process model. */
/* Create and register a handler to receive the end-simulation interrupt. *./
pro_handle = op_pro_create ("hndlr_end_sim", OPC_NIL);
op_intrpt_type_register (OPC_INTRPT_ENDSIM, pro_handle);
/* Create and register a handler to receive node failure and recovery intrpts. *./
pro_handle = op_pro_create ("hndlr_cond", OPC_NIL);
op_intrpt_type_register (OPC_INTRPT_FAIL, pro_handle);
op_intrpt_type_register (OPC_INTRPT_RECOVER, pro_handle);
Details
By default, all interrupts except for self, process, and procedure interrupts, are routed to the root process of the module where they arrive. However, two mechanisms are available for altering this behavior and causing such interrupts to be routed instead to another process within the module. The first mechanism makes use of the KP op_intrpt_type_register() to designate a process to receive interrupts of a particular type. A second mechanism, which is supported by the KP op_intrpt_port_register(), is more specific and allows direct delivery of interrupts to a designated process when stream or statistic interrupts arrive on particular input ports. Port registration overrides type registration when both are active.
Registration of a process via op_intrpt_type_register() remains in effect until a new call to the KP specifying the same interrupt type is made, thus replacing the registered process model with another. Default behavior, where interrupts are routed to the root process, can be restored simply by registering the root process as follows:
op_intrpt_type_register (OPC_INTRPT_STRM, op_pro_root (op_id_self ()));
Interrupts of type Self, Process, and Procedure already have specific targets implicitly defined when they are scheduled, and so this KP does not affect their processing.
Purpose
The ability to set up separate processes to handle particular interrupt types can be useful in order to break down complex process models or to relieve such models from handling special conditions, such as end-simulation interrupts, that do not directly relate to their principal function.
Errors
- Program Abort: KP requires process context. (if called from outside a processor or queue)
- Program Abort: Insufficient memory to create intrpt registration table.
- Program Abort: Segmentation violation. (due to a malformed process handle)
- Recoverable Error: Process handle is for destroyed process.
- Recoverable Error: Process handle is invalid.
- Recoverable Error: Process handle is for remote process.
- Recoverable Error: Interrupt type (
<intrpt_type>) does not support registration. - Recoverable Error: Interrupt type (
<intrpt_type>) is unrecognized.
Reference
- Use the KP op_pro_create() to create processes in the context of the currently executing module
- Use the KP op_intrpt_port_register() to direct stream and statistic interrupts to particular processes based on their arrival port index
- Use the KP op_pro_root() to obtain a handle for the root process of the surrounding module