op_ev_count_local()
Abstract
Obtains the number of events to be delivered to the current module.
Syntax
op_ev_count_local ()
| Argument | Type | Description |
|---|---|---|
| no arguments |
Return Type
int
the number of events destined for the invoking process including the current event and all forced events.
Example
/* Count the self interrupts this module scheduled */
/* by looping through all of the local events and */
/* verifying if each is a self interrupt. */
self_i_count = 0;
num_events = op_ev_count_local ();
next_event = op_ev_current ();
for (i = 0; i<num_events; i++)
{
if (op_ev_type (next_event) == OPC_INTRPT_SELF)
{
self_i_count++;
}
next_event = op_ev_next_local (next_event);
}
Details
The number of local events includes the current event, local forced events and local events in the event list. All events that will occur or are occurring at the process that invokes this KP are counted.
Purpose
Provides a count of the number of events that are scheduled to occur or are occurring at the invoking process. This number is useful as an upper bound when looping through all of the local events using op_ev_next_local().
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
- Program Abort KP requires process context. (e.g., due to invoking this KP from a pipeline stage)
Reference
- Use the KP op_ev_count() to obtain the total number of events
- Use the KP op_ev_current() to obtain the current event’s Evhandle