op_ev_count()
Abstract
Obtains the total number of events in the simulation that are currently scheduled or partially executed (sequential simulations only).
Syntax
op_ev_count ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
int
The number of events in the event list, including the current event and all forced events.
Example
/* Count the remote interrupts this module scheduled */
/* by looping through all of events and verifying if */
/* each is remote and from this module. */
ri_count = 0;
num_events = op_ev_count ();
next_event = op_ev_current ();
for (i = 0; i < num_events; i++)
{
if ((op_ev_type (next_event) == OPC_INTRPT_REMOTE) &&
(op_ev_src_id (next_event) == my_id))
{
ri_count++;
}
next_event = op_ev_next (next_event);
}
Details
The total number of events includes the current event, all forced events, and the events in the event list.
Purpose
Provides a mechanism for determining the number of events. This is useful, for example, as an upper bound when looping through all of the events using op_ev_next().
Note: This KP works only in a sequential simulation context. In a parallel simulation, where events in the current time cell might be executed in varying fashion based on what the threads are doing, it will act as if there are no events after the current one.
Errors
- No errors are trapped.
Reference
- Use the KP op_ev_count_local() to obtain the number of local events
- Use the KP op_ev_current() to obtain the current event’s Evhandle