op_intrpt_schedule_self()

Abstract

Schedules a self interrupt for the invoking process.

Syntax

op_intrpt_schedule_self (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

Excerpt from: example model (models/std/base); process model (acb_fifo); state (svc_start); enter execs.

/* 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 (op_sim_time () + pk_svc_time, 0);

/* the server is now busy. */
server_busy = 1;

Details

Invoking this KP places a new event on the simulation event list; this new event represents a self interrupt that is scheduled to be delivered at the specified time. As soon as the event is scheduled, this KP returns control to the invoking process. During the delay interval, the invoking process is free to pursue any activities. The event will take place at the scheduled simulation time, but not before the execution of other higher priority events scheduled for that specific simulation time. When all earlier events have been executed, and the self interrupt event is at the head of the simulation event list, its simulation time is established as the current simulation time and the event is executed. The execution of the event causes a self interrupt to be delivered to the invoking process. The process can obtain the specified code associated with the interrupt via the KP op_intrpt_code().

In cases where a self interrupt is representing a time-out, or some similar event, it is sometimes useful to cancel the self interrupt if it becomes unnecessary (for example, when a time-out needs to be revoked due to an ack being received before the time-out elapses). Cancelling an interrupt requires that the event handle returned by this KP be stored in a state variable, to be later passed to the KP op_ev_cancel(), as in the following examples:

/* state variable declaration */
Evhandle \evh;

/* self interrupt scheduling */
evh = op_intrpt_schedule_self (sch_time, 5);

/* self interrupt cancelling */
op_ev_cancel (evh);

Purpose

Provides a mechanism for scheduling a self interrupt (i.e., a “wake up call”) for a specified future time. This is often used to delimit the end of an interval which represents a mode of the process. In the case of modeling a time-out, the mode is waiting for a packet arrival, and the time-out self interrupt signifies the end of the interval. In the case of modeling a processing delay, the mode is performing a task, and the “end-of-task” self interrupt signifies the completion of the task and releases a product of the task (i.e., a processed packet). At the end of the interval, the process will typically revert to an idle mode, or re-evaluate what other pending tasks it should undertake.

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

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com