op_ev_count_local()
摘要
获取将投递到当前模块的事件数量。
语法
op_ev_count_local ()
| 参数 | 类型 | 说明 |
|---|---|---|
| 无参数 |
返回类型
int
发往调用进程的事件数量,包括当前事件和所有强制事件。
示例
/* 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);
}
详情
本地事件数量包括当前事件、本地强制事件以及事件列表中的本地事件。所有将在调用该内核过程的进程中发生或正在发生的事件都会被计入。
用途
提供调用进程上计划发生或正在发生的事件数量统计。在使用 op_ev_next_local() 遍历所有本地事件时,该数量可用作循环的上界。
**注意:**该内核过程仅在顺序仿真上下文中有效。在并行仿真中,当前时间单元中的事件可能根据各线程的行为以不同的方式执行,此时它将表现为当前事件之后没有任何事件。
错误
- 程序中止 内核过程要求进程上下文。(例如,由于在流水线阶段中调用该内核过程)
参考
- 使用内核过程 op_ev_count() 获取事件总数
- 使用内核过程 op_ev_current() 获取当前事件的 Evhandle