op_intrpt_schedule_self_mt()
Abstract
Schedules a self interrupt that is explicitly guaranteed by the client to be safe for parallel execution.
Syntax
op_intrpt_schedule_self_mt (time, code)
| Argument | Type | Description |
|---|---|---|
time |
double |
scheduled time for the interrupt [This value is an absolute simulation time, rather than a delay relative to the current simulation time. If the “sim_time_quantum“ preference has a value other than 0.0, time will be truncated internally to a multiple of the specified quantum.] |
code |
int |
user-defined numeric code for association with the interrupt [This value is an arbitrary, user-defined integer that can be used as an identification code for the scheduled interrupt; the code can be obtained when the interrupt invokes the process, using the KP op_intrpt_code(). You can assign a text string that will be printed along with this code when it appears in ODB event banners and traces. See “Interrupt Code Map“ on page 507 for details.] |
Return Type
Evhandle
Event handle for the scheduled interrupt.
[This returned value can be stored in a state variable for possible later use to identify the interrupt in an invocation of op_ev_cancel().]
Example
/* get a handle on packet at head of subqueue 0 */
/* (this does not remove the packet) */
pkptr = op_subq_pk_access (0, OPC_QPOS_HEAD);
/* determine the packet’s length (in bits) */
pk_len = op_pk_total_size_get (pkptr);
/* determine the time required to complete */
/* service of the packet */
pk_svc_time = pk_len / service_rate;
/* schedule an interrupt for this process */
/* for the time when service ends. */
op_intrpt_schedule_self_mt (op_sim_time () + pk_svc_time, 0);
/* the server is now busy. */
server_busy = 1;
Details
Same as op_intrpt_schedule_self(), except for allowing parallel execution regardless of the MT-safety rules of the module.
Purpose
Provides a mechanism for scheduling a self interrupt that will be considered for parallel execution if a parallel kernel is being used. By using this KP, you guarantee the interrupt event to be MT-safe; thus, it will be scheduled for parallel execution without evaluating the usual MT-safety rules of the current module. This KP behaves identically to op_intrpt_schedule_self() in sequential kernels.
Errors
- Program Abort: Allocation of memory failed.
- Program Abort: KP requires process context. (if called from outside a processor or queue)
- Recoverable Error: Specified time (
<time>) is less than current time. - Recoverable Error: Specified time (
<time>) is an invalid double value.
Reference
- Use the KP op_intrpt_schedule_remote() to schedule a remote interrupt
- Use the KP op_intrpt_force_remote() to force a remote interrupt
- Use the KP op_intrpt_schedule_call() to schedule a procedure interrupt
- Use the KP op_ev_cancel() to cancel a pending self, remote, or procedure interrupt
- Use the KP op_intrpt_code() to obtain the code associated with an incoming interrupt