op_ev_stat()
摘要
获取与指定事件关联的输入统计量索引。
语法
op_ev_stat (evhandle)
| 参数 | 类型 | 说明 |
|---|---|---|
evhandle |
Evhandle |
标识该事件的事件句柄 [事件句柄可以从本包中的多个内核过程获取,例如 op_ev_current()、op_ev_seek_time() 和 op_ev_next()。] |
返回类型
int
与指定事件关联的输入统计量索引。
该输入统计量索引是与指定事件关联的统计量导线的目标统计量的索引。如果发生可恢复错误,将返回常量 OPC_STAT_INVALID。
示例
/* Determine if any interrupts on the Q_LEN statwire are scheduled */
/* to occur in the next five seconds. */
stat_intrpt_found = 0;
time_boundary = op_sim_time () + 5.0;
event = op_ev_next (op_ev_current ());
while (op_ev_valid (event))
{
/* If the event is after the time boundary, then quit looking. */
if (op_ev_time (event) > time_boundary)
break
/* If it is a statwire intrpt on the Q_LEN statwire, note it and break out. */
if ((op_ev_type (event) == OPC_INTRPT_STAT) &&
(op_ev_stat (event) == Q_LEN_STATWIRE))
{
stat_intrpt_found = 1;
break;
}
/* Didn’t match, so try the next local event. */
event = op_ev_next_local (event);
}
详情
只有当该内核过程应用于与传入统计量导线关联的事件时,才会产生有效结果。符合这一限制的唯一事件类型是统计量中断。注意 op_ev_stat (op_ev_current()) 等价于 op_intrpt_stat()。
用途
提供了一种确定与事件关联的输入统计量的机制。
错误
- 程序中止:段错误。(由于格式错误的事件句柄)
- 可恢复错误:事件句柄指向的事件无效或当前未被计划。
- 可恢复错误:事件与统计量导线无关。
参考
- 使用内核过程 op_ev_valid() 判断 Evhandle 是否有效
- 使用内核过程 op_ev_type() 确定事件的类型
- 使用内核过程 op_ev_code() 确定自中断、远程中断或组播中断的代码
- 使用内核过程 op_ev_strm() 确定与流中断关联的数据流索引
- 使用内核过程 op_ev_time() 确定事件的计划时间
- 使用内核过程 op_ev_ici() 获取与事件关联的 ICI