op_id_self()
Abstract
Obtains the object ID of the surrounding processor or queue.
Syntax
op_id_self ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
Objid
Object ID of the surrounding processor or queue.
The special value represented by the symbolic constant OPC_OBJID_INVALID will be returned if this KP is invoked from a non-process context (e.g., a context other than a processor or a queue).
Example
Excerpt from: example model (models/std/base); process model (acb_fifo); state (init); enter execs.
/* initially the server is idle */
server_busy = 0;
/* get queue module’s own object ID */
own_id = op_id_self ();
/* get assigned value of server processing rate */
op_ima_obj_attr_get (own_id, "service_rate", &service_rate);
Details
If this KP is not invoked from a process context (i.e., from a process that is running in a processor or queue), the returned value will be the constant OPC_OBJID_INVALID. Scheduled procedure calls, implemented via the op_intrpt_schedule_call() interface, inherit the context from which they were called; therefore if a procedure call is scheduled by a process, then it can expect a valid result from op_id_self(). However, pipeline stages are not considered process contexts, so they will be returned the value OPC_OBJID_INVALID.
Purpose
Provides a mechanism for a process to obtain its self object ID, so that it can access the values of its own attributes via the KP op_ima_obj_attr_get(). This is also the first step in obtaining the object ID of the surrounding node or subnet, via successive calls to the KP op_topo_parent().
op_id_self() can also be used in order to test that the current context is that of a process, since the constant OPC_OBJID_INVALID will be returned otherwise.
Errors
- No errors are trapped.
Reference
- Use the KP op_topo_parent() to obtain the object ID of an object’s parent
- Use the KP op_topo_child() to obtain the object ID of an object’s child
- Use the KP op_ima_obj_attr_get() to obtain the value of an object’s attribute
- Use the KP op_ima_obj_attr_set() to assign the value of an object’s attribute