op_pro_invoker()

Abstract

Determines whether an active process was invoked by the Kernel (direct mode) or by another process (indirect mode). In the case of indirect mode, the process handle of the invoking process is returned.

Syntax

op_pro_invoker (pro_handle, invnode_ptr)
Argument Type Description
pro_handle Prohandle Process handle of the process whose invoker is to be determined
invnode_ptr int* Output argument (address of integer to be modified).
When this KP returns, the referenced integer contains a value indicating whether the process was invoked directly by the Kernel to handle an interrupt, or indirectly by another process via the KP op_pro_invoke(). This value is the constant OPC_PROINV_DIRECT if the specified process was invoked directly; the value OPC_PROINV_INDIRECT is installed if the process was invoked via op_pro_invoke(). The value OPC_PROINV_ERROR is used to indicate that the KP did not complete (see Errors section)

Return Type

Prohandle

Process handle of the process that invoked the process specified by the pro_handle argument of this KP. This process handle is invalid if an error occurs or if the specified process was invoked directly by the Kernel to handle the current interrupt.

Example

/* Make sure that we have arrived here as a result of a stream interrupt. */
if (op_intrpt_type () == OPC_INTRPT_STRM)
	{
	/* Determine if this process is the first to be invoked to handle the current intrpt. */
	invoker_ph = op_pro_invoker (op_pro_self (), &inv_mode);

	/* If the process is the first, then acquire the arriving packet. */
	if (inv_mode == OPC_PROINV_DIRECT)
		pkptr = op_pk_get (op_intrpt_strm ());

	/* Otherwise, get the packet from the args passed by the invoking process. */
	else
		{
		pkptr = (Packet*) op_pro_argmem_access ();

		/* Schedule a process interrupt for the invoking process in HOLD_TIME sec. */
		/* (this is the time at which the packet's delay has elapsed.  */
		op_intrpt_schedule_process (invoker_ph, op_sim_time () + HOLD_TIME, PK_ELAPSED);
		}

	/* Enqueue the received packet (regardless of invocation mode). */

Details

This KP is typically used to analyze the invocation of the currently executing process (i.e., the one calling the KP). However, it may be used to determine the invocation mode and invoker of any active process specified by the pro_handle argument. An active process is any process that has been invoked and not yet returned from invocation. In cases where several processes invoke each other in turn via op_pro_invoke(), this KP may be applied recursively to the returned process handles in order to trace back the complete invocation "stack" to the beginning of the interrupt.

Purpose

This KP is typically used to differentiate between invocations made directly by the Simulation Kernel in response to an interrupt for the surrounding module (direct mode), and invocations by another process via op_pro_invoke() (indirect mode). This information cannot be obtained by any KPs in the Intrpt package because multiple invocations can occur within a single interrupt and interrupt-related information remains constant throughout a single event. This information may be used to determine the significance of an invocation and what processing should occur. For indirect invocations, the invoking process can also be determined, possibly to allow the invoked process to respond in some way when there are multiple potential invokers.

Errors

  • Program Abort: segmentation violation. (due to a malformed process handle or invalid address for the invmode_ptr output argument).
  • Recoverable Error: Process handle is invalid.
  • Recoverable Error: Process handle is for destroyed process (<proc_id>).

Reference

  • Use the KP op_pro_parent() to obtain a process handle for a process' parent
  • Use the KP op_pro_create() to create a new process and obtain a process handle for it
  • Use the KP op_pro_invoke() to invoke another process in the same surrounding module
  • Use the KP op_pro_root() to obtain a process handle for the root process of the surrounding module
  • Use the KP op_pro_id() to obtain a unique identifier for a process given its process handle
  • Use the KP op_pro_self() to obtain a process handle for the currently executing process

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