op_pro_mod_objid()

摘要

获取拥有某进程的模块的对象 ID。

语法

op_pro_mod_objid (pro_handle)
参数 类型 说明
pro_handle Prohandle 需要查找其所属模块的进程的进程句柄

返回类型

Objid

拥有指定进程的模块的对象 ID。若发生错误,返回的对象 ID 将是符号常量 OPC_OBJID_INVALID。

示例

/* Loop through all the nodes in the system. */
for (i = 0; i < num_nodes; i++)
	{
	/* Obtain the globally administered node information data */
	/* structure for the i_th node.                          */
	ni_ptr = &Tm_Node_Info_Array [i];

	/* Obtain a process handle for the "controller" process in the i_th node, */
	/* and use it to determine the object id of the controller module.       */
	cntl_objid = op_pro_mod_objid (ni_ptr->cntl_ph);

	/* Test for an error in the object id query. This would result */
	/* if the process handle was one obtained as an error or if it */
	/* refers to a process that has been destroyed previously.     */
	if (cntl_objid != OPC_OBJID_INVALID)
		{
		/* Deliver a packet from the command buffer to each controller. */
		pkptr = op_subq_pk_remove (TP_SUBQ_COMMAND, OPC_QPOS_HEAD);
		op_pk_deliver (cntl_objid, TP_CNTL_INSTRM_COMMAND);
		}
	}

详情

每个进程都由一个队列或处理器模块拥有。这一所有权属性在进程创建时确定。对于模块的根进程,这发生在仿真开始时由仿真内核自动创建它之时。当根进程创建其他(子)进程时,这些子进程同样归该模块所有;它们的子进程也是如此,依此类推。

通常,当进程只笼统地知道某个进程句柄,而需要获知其所属模块以便修改属性或与该模块通信时,会调用 op_pro_mod_objid()。获取另一模块中某进程的进程句柄可以通过多种机制,包括共享全局变量,以及将进程句柄嵌入传输的数据包或 ICI 中。

用途

当某进程的句柄可被其自身模块之外的其他进程获得时,op_pro_mod_objid() 通常很有用。该内核过程使一个进程能够确定所属模块的对象 ID,并可能利用该对象 ID 通过 op_pro_root() 获取该模块的根进程,或向远程模块投递某种中断,而无需具体指定接收该中断的进程。但请注意,该内核过程并不适合用于确定拥有当前正在执行进程的模块的对象 ID,因为调用内核过程 op_id_self() 可以更简单地获得这一信息。

错误

  • 程序中止:段违例(由于进程句柄格式错误)。
  • 可恢复错误:进程句柄无效。
  • 可恢复错误:进程句柄指向已被销毁的进程(<proc_id>)。

参考

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