ICI Mechanics

To associate an ICI with an event, the Simulation Kernel relies on a mechanism called ICI installation. Each process (a processor or queue module may contain multiple processes) has at most one installed ICI at any given time. Initially, a process is considered to have no ICI installed; subsequently the process may install other ICIs by calling the KP op_ici_install() and passing the address of the ICI of interest. An ICI remains installed until another takes its place.

The Simulation Kernel automatically associates a process’ installed ICI with the events that the process generates. Because an ICI can remain installed after it has been associated with an event, it can also become associated with subsequent events. In fact, the same installed ICI address will be associated with every event scheduled by a process, until it is replaced by another ICI. One way to avoid having unintended associations between ICIs and events is to restore the initial condition (i.e., no ICI is installed) after each event-scheduling action; this can be done by calling the KP op_ici_install() with the symbolic constant OPC_NIL. However, in general this is not necessary, because the mere association of an ICI with an event that does not make use of it is of no consequence. In other words, if the destination context of an event does not make use of an ICI, no adverse effect can result from the ICI simply being available.

Operations on ICIs

ICIs are dynamic objects that must be created by processes that want to associate information with events that they schedule. The KP op_ici_create() returns an ICI address (i.e., memory pointer) that can be stored in a process’ state, temporary, or other variables. All subsequent operations on ICIs must then refer to the ICIs by address, rather than directly as data-structures.

A dedicated package of KPs supports operations on ICIs such as creation, setting and getting of attributes, destruction, installation, etc. The capabilities provided by this package are summarized in the table below. In addition, a KP from the Interrupt package is used to obtain an ICI in an event’s destination context. Detailed explanations of each KP are provided in the Discrete Event Simulation API.

Table 100: ICI-Related Kernel Procedures

Kernel Procedure Provided Capability
op_ici_attr_exists() determines if an attribute, specified by name, is defined within an ICI’s format
op_ici_attr_get_dbl()
op_ici_attr_get_int32()
op_ici_attr_get_int64()
op_ici_attr_get_ptr()
obtain the value of an ICI attribute of a specific type, specified by name
op_ici_attr_set_dbl()
op_ici_attr_set_int32()
op_ici_attr_set_int64()
op_ici_attr_set_ptr()
assign the value of an ICI attribute of a specific type, specified by name
op_ici_create() creates a new ICI with a specified format; the ICI’s address is returned
op_ici_destroy() releases memory taken by an ICI
op_ici_format() obtains the name of an ICI’s format
op_ici_format_print_proc_set() registers a function used to print a custom ICI format
op_ici_install() installs an ICI as “current” for a process such that the ICI becomes associated with events scheduled by the process
op_ici_print() prints the contents of an ICI to standard output
op_intrpt_ici() obtains the address of the ICI associated with the currently executing event
op_pk_ici_get() obtains the pointer to the ICI that has been previously associated with the packet via the KP op_pk_ici_set().
op_pk_ici_set() creates an association between a packet and an ICI by storing the specified ICI pointer in the packet.

Standard ICI Lifecycles

The principal events in an ICI’s existence are creation, destruction, and installation. These determine the times at which an ICI enters and exits circulation, and when it becomes eligible for association with an event. In addition, intermediate operations such as modification and extraction of attributes are typically executed. Because there are no strict ownership controls on ICIs, as there are on packets, any process that has access to an ICI’s address can do these operations. For example, an ICI may be destroyed by the process that created it, or by one of the processes that have received it. Similarly, multiple processes can concurrently have access to the same ICI and cause modifications that will be visible to each other.

While the Simulation Kernel imposes no strict discipline on the usage of ICIs, certain standard patterns of creation, installation, and destruction are recommended to avoid complicated interactions between processes that share ICIs. Each of these ICI lifecycles is applicable to different types of modeling situations.

Instantiation on a Per-Use Basis

This technique imposes the most rigorous control on access to ICIs, because it treats them as though they were packets, disallowing shared access by multiple processes. The communication of information in association with an event is supported by the following sequence of operations:

  1. The source process creates an ICI by calling the KP op_ici_create().
  2. The source process stores information in the ICI’s attributes by calling one of the op_ici_attr_set… KPs for each relevant attribute.
  3. The source process installs the ICI by calling op_ici_install().
  4. The source process takes an action that generates an event (e.g, a packet is sent, or a self interrupt is scheduled).
  5. When the event occurs and results in an interrupt, the interrupted process obtains the ICI by calling op_intrpt_ici().
  6. The interrupted process extracts information that it needs from the ICI by calling one of the op_ici_attr_get… KPs.
  7. The interrupted process destroys the ICI by calling op_ici_destroy().

Note that when per-use instantiation is employed, the source process no longer manipulates the ICI after having generated the event. The responsibility for destroying the ICI and releasing memory associated with the ICI’s attributes therefore belongs to the destination process.

Permanent ICIs

In certain situations, per-use instantiation results in an alternating sequence of creation and destructions of ICIs of the same type. A straightforward optimization therefore consists of creating the ICI only once, and never destroying it; the source process need only update the ICI’s attribute values and install it before generating an event (the installation is still required, in case the process also makes use of other ICIs). The sequence of operations for the source and destination processes is as follows:

  1. The source process creates an ICI at initialization (or perhaps some later time, but this should occur only once) by calling op_ici_create().
  2. When the source process is about to take an action that will generate an event and the ICI is to be associated with that event, it assigns correct values to the ICI’s attributes by calling one of the op_ici_attr_set… KPs.
  3. The source process installs the ICI by calling op_ici_install().
  4. The source process takes an action that generates an event (e.g, a packet is sent, or a self interrupt is scheduled).
  5. When the event occurs and results in an interrupt, the interrupted process obtains the ICI by calling op_intrpt_ici().
  6. The interrupted process extracts information that it needs from the ICI by calling one of the op_ici_attr_get… KPs.

Note that under this scheme, the ICI is never destroyed. However, this does not result in memory being wasted because the same ICI is continually recycled.

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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