op_intrpt_port_register()
Abstract
Registers a process as the direct recipient of stream or statistic interrupts that arrive at a particular port of the currently executing module.
Syntax
op_intrpt_port_register (port_type, port_index, pro_handle)
| Argument | Type | Description |
|---|---|---|
port_type |
int |
type of port for which interrupt registration is to be activated. [This is an integer symbolic constant that specifies either a stream or statistic input. Possible values are OPC_PORT_TYPE_STRM and OPC_PORT_TYPE_STAT.] |
port_index |
int |
index of port of for which interrupt registration is to be activated. [Indices for both stream and statistic wire inputs begin at zero for the first port.] |
pro_handle |
Prohandle |
Handle for process designated as the direct recipient of interrupts matching the port type and port index criteria. [This must be the handle of a valid (i.e., existing) process.] |
Return Type
void
no return value
Example
/* Set up separate handling process for each */
/* supported input stream, since each stream */
/* will support one remote connection. */
for (i = 0; i < num_sup_streams; i++)
{
/* Create a packet handler process. */
handler_pro = op_pro_create ("pkt_handler", OPC_NIL);
/* Request that the kernel notify this new process directly */
/* (i.e., without notifying the root process) when packets */
/* arrive on its stream. */
op_intrpt_port_register (OPC_PORT_TYPE_STRM, i, handler_pro);
}
Details
By default, stream or statistic 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 all interrupts of type stream or statistic.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.
The effect of using op_intrpt_port_register() can be “undone” by calling the KP op_intrpt_port_deregister() at any subsequent point in the simulation.
Port types are either stream or statistic and are represented by the symbolic constants OPC_PORT_TYPE_STRM and OPC_PORT_TYPE_STAT.
Purpose
This KP is useful when modular processes can be written to independently handle the flow of events generated at individual ports of a module. By configuring the module to directly route interrupts to appropriate processes, one can avoid the overhead of interrupting the root process at each event, only to then have it hand off the interrupt to another process. This also simplifies the design of the root process, since it no longer needs to play the role of an “event coordinator” for the entire module.
Errors
- Program Abort: KP requires process context. (if called from outside a processor or queue)
- 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: Statistic index (
<port_index>) is out of range. - Recoverable Error: Stream index (
<port_index>) is out of range. - Recoverable Error: Port type (
<port_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_deregister() to reverse the effect of calling
op_intrpt_port_register() - Use the KP op_intrpt_type_register() to direct interrupts to particular processes based on their type