op_pro_create()

Abstract

Creates a new process as an instance of the specified process model and allows for the installation of parent-to-child shared memory to serve as a communication mechanism between the current process and the created child process.

Syntax

op_pro_create (model_name, ptc_mem_ptr)
Argument Type Description
model_name const char* Name of process model to be instantiated
[The selected process model must be incorporated into the overall model by direct assignment to a processor or queue or by reference as a child of another incorporated process model.]
ptc_mem_ptr void* Address of parent-to-child memory block to be shared by current process and newly created one
[This memory block has a format that is user defined; by convention, the value OPC_NIL should be passed if no memory is to be shared between the current process and the child process.]

Return Type

Prohandle

Process handle used to perform further operations related to the created child process.

Example

/* Select a port number for a new session being initiated. */
port_num = tp_port_select ();

/* Create a session-status data structure to allow 															*/
/* communication between this (root) process and the															*/
/* session process about to be created.															*/
ss_ptr = op_prg_mem_alloc (sizeof (Tp_Session_Status));

/* Set up information needed by the session process.															*/
ss_ptr->dest_host = dest_host;
ss_ptr->dest_port = dest_port;

/* Create a new process to manage the session and retain 																	*/
/* its handle in the session process table. 																	*/
tp_sess_proc_table [port_num] = op_pro_create (“tp_session”, ss_ptr);

/* Invoke the process for its initialization (op_pro_create() 																		*/
/* does not automatically invoke the child process)																		*/
op_pro_invoke (tp_sess_proc_table [port_num], OPC_NIL);

Details

The Simulation Kernel supports the concurrent existence of any number of processes of various types within a single queue or processor module. All of these processes, with the exception of the root process, are created via the KP op_pro_create(). This KP will succeed only if the supplied argument process_model refers to a process that has been declared to exist in the currently executing simulation. Declaration of a process model occurs implicitly when it is assigned to the process model attribute of any processor or queue module in the simulated system; or a process may be declared as a child of another process via a declaration mechanism in the Process Editor.

Each process that is created via op_pro_create() can (at the option of the parent process) make use of shared memory to communicate with the process that created it. The shared memory is a user-defined block of memory whose address must be passed as the argument ptc_mem_ptr of this KP. This is the only time at which parent-to-child shared memory can be established for this pair of processes. The child process can obtain the address established via this mechanism by calling the procedure op_pro_parmem_access().

By convention, if the parent wishes not to provide for shared memory when creating the child process, the symbolic constant OPC_NIL should be passed for the value of ptc_mem_ptr.

Purpose

Provides a process with the ability to create child processes that operate within the same module. Each child process exists as an independent instance of a process model, maintaining its own state.

Errors

  • Program Abort: KP requires process context.
  • Program Abort: Unable to create process (<model_name>).
  • Program Abort: Allocation of descriptor failed for process (<model_name>).
  • Program Abort: Initialization of process (<model_name>) failed.
  • Recoverable Error: Process model (<model_name>) is undeclared.

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