op_pro_svar_get()

Abstract

Obtains a pointer to a state variable within the specified process.

Syntax

op_pro_svar_get (prohandle, svar_name)
Argument Type Description
prohandle Prohandle Process handle of the process containing the specified state variable.
svar_name const char * Name of the state variable-of-interest.

Return Type

void *

Pointer to the requested state variable.

Example

Prohandle    child_pro_handle;
int          *child_int_svar_ptr;

/* Create a child process */
child_pro_handle = op_pro_create ("Child_process_model", NULL);

/* Obtain pointer to a child process state variable */
child_int_svar_ptr = op_pro_svar_get (child_pro_handle, "int_var");

/* change child's process state varable value */
*child_int_svar_ptr = 10;

Details

Although this KP is MT safe (as described in "Multi-Threading Safety“ on page 11), it must be used with care if multiple clients are accessing or modifying shared svar information.

Purpose

Provides an alternative mechanism for interprocess communications (in addition to packets, ICIs, remote interrupts, statistic wires, global variables, and remotely setting attributes using the KP op_ima_obj_attr_set()). By having access to another process’ state variables, a process can communicate via semaphores, monitor execution status, or modify the operation of the remote process. The programming paradigm for remote state variables is similar to the concept of shared registers on a memory-mapped bus-interfaced computer peripheral.

Errors

  • Program Abort: Segmentation violation. (due to a malformed process handle)
  • Recoverable Error: Process handle is invalid.
  • Recoverable Error: State variable (<svar_name>) is not defined in the process (<proc_id>).

Reference

  • Use the KP op_ima_obj_svar_get() to obtain a pointer to a specified state variable within a processor or queue object.

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