op_q_stat()
摘要
获取由外围队列自动计算的某个统计量的值;该统计量针对整个队列(而非单个子队列)。
语法
op_q_stat (stat_index)
| 参数 | 类型 | 说明 |
|---|---|---|
stat_index |
int |
目标队列统计量的数值索引 [这是一个整数代码,代表可能的队列统计量类型之一(参见 表 74 “Queue Statistic Symbolic Constants“ 第 22 页)。] |
返回类型
double
外围队列中指定统计量的当前值。
若发生可恢复错误,将返回常量 OPC_DBL_INVALID。
示例
/* determine the type of the interrupt */
if (op_intrpt_type () == OPC_INTRPT_REMOTE)
{
/* cold reboot: total loss of queued packets */
if (op_intrpt_code () == COLD_REBOOT)
{
/* record the number of packets lost */
num_lost_packets += op_q_stat (OPC_QSTAT_PKSIZE);
/* flush the queue of its contents */
op_q_flush ();
}
/* prioritize: loop through and sort all subqueues */
else if (op_intrpt_code () == PRIORITIZE)
{
num_subqs = op_topo_child_count (op_id_self (), OPC_OBJTYPE_SUBQ);
for (i = 0; i < num_subqs; i++)
op_subq_sort (i);
}
}
详情
Q 包的内核过程只能在运行于队列模块上的进程的上下文中调用(或由队列进程直接或间接调用的函数中调用);从运行在处理器上的进程或管道阶段模型中调用它们将导致错误。
有关队列统计量的更多信息,参见 第 6 章 “Node Domain” 第 267 页。
用途
提供一种获取外围队列状态、运行和性能统计量的机制。有十多个队列统计量是因该内核过程的查询而计算的(即“按需”计算)。队列统计量可用于自适应地修改排队算法的行为;例如,可以将数据包在队列中经历的平均延迟与某个阈值比较,该阈值会改变排队过程处理传入数据包的方式。
错误
- 程序中止:KP 需要队列上下文。
- 可恢复错误:队列统计量索引 (
<stat_index>) 超出范围。
参考
- 使用内核过程 op_subq_stat() 获取某个子队列统计量的值
- 使用内核过程 op_stat_local_read() 获取队列输入统计量的值