op_ev_count()
摘要
获取仿真中当前处于计划执行或部分执行状态的事件总数(仅适用于顺序仿真)。
语法
op_ev_count ()
| 参数 | 类型 | 说明 |
|---|---|---|
| 无参数 |
返回类型
int
事件列表中的事件数量,包括当前事件和所有强制事件。
示例
/* 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);
}
详情
事件总数包括当前事件、所有强制事件以及事件列表中的事件。
用途
提供了一种确定事件数量的机制。例如,在使用 op_ev_next() 遍历所有事件时,它可以用作循环的上界。
**注意:**该内核过程仅在顺序仿真上下文中有效。在并行仿真中,当前时间单元中的事件可能根据各线程的行为以不同的方式执行,此时它将表现为当前事件之后没有任何事件。
错误
- 不捕获任何错误。
参考
- 使用内核过程 op_ev_count_local() 获取本地事件的数量
- 使用内核过程 op_ev_current() 获取当前事件的 Evhandle