op_pro_modmem_install()

Abstract

Installs a memory address to be associated with the current module and which can be accessed by other processes via the KP op_pro_modmem_access().

Syntax

op_pro_modmem_install (mem_ptr)
Argument Type Description
mem_ptr void* address of the memory block to be installed as module-wide shared memory
[This memory block can only be allocated and initialized by user-defined processes. The Simulation Kernel maintains only the supplied address and associates it with the current module. The Kernel has no knowledge of the block's size.]

Return Type

void

No return value.

Example

/* Allocate module-wide variable block. */
tp_mv_ptr = (Tp_Proc_Var*) op_prg_mem_alloc (sizeof (Tp_Proc_Var));

/* If the allocation was successful, initialize the variable block. */
if (tp_mv_ptr != OPC_NIL)
	{
	/* Clear out counters and statistics. */
	tp_mv_ptr->num_sess_active = 0;
	tp_mv_ptr->total_pkts = 0;
	tp_mv_ptr->total_bytes = 0;
	tp_mv_ptr->accum_pk_delay = 0.0;
	tp_mv_ptr->num_discards = 0;

	/* Set module-wide timers. */
	tp_global_timers_init (tp_mv_ptr);

	/* Install the module-wide variable block for all dynamic process to access. */
	op_pro_modmem_install (tp_mv_ptr);
	}

Details

This KP installs a memory address that is maintained for the queue or process 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 setup 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 if it calls 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 for memory conservation, 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