op_pro_modmem_access()

Abstract

Obtains the memory address installed via op_pro_modmem_install() for the queue or processor module that owns the currently executing process.

Syntax

op_pro_modmem_access ()
Argument Type Description
no arguments

Return Type

void*

Address of the user-defined memory block installed for access by all of the processes in the queue/processor module. This address can be installed by calling the KP op_pro_modmem_install(). If no processes in this module have installed an address, then this return value will be the symbolic constant OPC_NIL.

Example

/* Get the pointer to the module wide variables installed by the root process. */
mod_vars = (X25T_DTE_Mod_Vars *) op_pro_modmem_access ();

/* Get the pointer to the channel block for this channel. */
chan_vars = (X25T_Channel *) op_pro_parmem_access ();

/* Initialize channel state variables. */
chan_vars->number = chan_number;
chan_vars->process = op_pro_self ();
chan_vars->local_addr = local_addr;
chan_vars->remote_addr = remote_addr;
chan_vars->permanent = 0;
chan_vars->data_link = X25C_DTE_DL_OUTSTRM;
chan_vars->application = appl_stream;

Details

This KP returns a memory address that is maintained for the queue or processor module that owns the currently executing process. Each queue or processor maintains only one such address variable and the Simulation Kernel allows processes access to it via the KPs op_pro_modmem_access() and op_pro_modmem_install(). Initially this memory address is set to the value of the symbolic constant OPC_NIL. This value will remain in effect until a call to op_pro_modmem_install() replaces it with another.

The intended use of this pair of KPs is to allow processes to set up a common storage area for information that must be shared among multiple processes in a single module. Typically one process will be responsible for allocating (e.g., via op_prg_mem_alloc()) a block of memory large enough to hold an application-specific data structure; this process will then initialize the data structure and install the memory block's address for access by other processes. Processes can update and/or examine the contents of this data-structure as needed to implement their function and coordinate their activities with other processes.

The installed memory address can be replaced by any process in the module by calling op_pro_modmem_install() again. If the address being replaced is that of dynamically allocated memory, it is the responsibility of the processes to deallocate it to conserve memory, if necessary; the previous value will no longer be accessible via op_pro_modmem_access(). The constant OPC_NIL may be installed to indicate the absence of any shared memory for the module's processes.

Purpose

Provides a mechanism to share memory among all processes in a given module. Any process may call the KP op_pro_modmem_install() to register a memory address to be accessed by all processes of a module. The Simulation Kernel stores this address in the module and allows it to be retrieved by calling op_pro_modmem_access(). The structure of the referenced memory block and the interpretation of its contents are user-defined.

This mechanism is intended to support designs that require multiple processes in the same module to coordinate their activities by modifying and examining variables held within a common storage area.

Errors

  • Program Abort: KP requires process context.

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