op_pro_argmem_access()

Abstract

Obtains address of argument memory passed by invoking process.

Syntax

op_pro_argmem_access()
Argument Type Description
no arguments

Return Type

void*

Address of user-defined memory block supplied by invoker of process.

[When a process is invoked directly by the Simulation Kernel or when the invoking process wishes to pass no argument memory, this return value will be the symbolic constant OPC_NIL.]

Example

/* Obtain the address of the argument memory block passed by calling process. */
arg_mem_ptr = op_pro_argmem_access ();

/* If there are arguments present, examine them to 															*/
/* determine the reason for invocation. 															*/
if (arg_mem_ptr != OPC_NIL)
	{
	/* Cast the argument memory into specific data-structure form. */
	pkt_hndlr_ptr = (Pkt_Hndlr_Req_Args*) arg_mem_ptr;

	/* Process the request according to its type. */
	switch (pkt_hndlr_ptr->type)
		{
		case PHR_REQ_INBOUND:
			phr_pkt_inbound (pkt_hndlr_ptr->pkptr, pkt_hndlr_ptr->source);
			break;

		case CHR_REQ_CALL_REMOVE:
			phr_pkt_outbound (pkt_hndlr_ptr->pkptr, pkt_hndlr_ptr->dest);
			break;
		}

Details

Argument memory is a user-defined memory block whose address is passed by a process invoking another one by means of the KP op_pro_invoke(). The format and contents of the memory are user-defined and only the address is managed by the Simulation Kernel. The argument memory address passed via op_pro_invoke() is accessible throughout the duration of the called process.

For processes invoked directly by the Simulation Kernel (i.e, the root process, processes receiving self interrupts, or processes registered via the Interrupt package KPs), the value returned by op_pro_argmem_access() will be the symbolic constant for a nil address, OPC_NIL. Processes susceptible of being called both directly by the kernel and by means of op_pro_invoke() should check that the address returned is not equal to OPC_NIL before using this pointer to access argument values, or a segmentation violation error can occur.

Use of the argument memory mechanism is optional when calling op_pro_invoke(). Depending upon the application, it is possible that the invoked process will have no need for values to be passed in, or to return any data to the invoking process. In such cases, the convention is that the call to op_pro_invoke() should pass the symbolic constant OPC_NIL where the argument memory is expected.

Purpose

Provides a mechanism for sharing memory between an invoked process and an invoking process. The memory can be set up before the invocation to contain “input argument” values which the invoked process can examine and make use of in its handling of the event. Similarly, the invoked process can modify the memory to return “output arguments” to the invoking process which can examine the contents of the memory after the KP op_pro_invoke() returns.

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