读取链式计数器

Reading a chained counter

As the multiple 16b registers cannot be read atomically, a wrap from one value to the next can occur at any time, leading to an inconsistent readout of the current value. The usual procedure to overcome it is the following:

1. Read all 16b values of the chained CNT registers in the first set of variables, excluding the least significant CNT register
2. Read all 16b values again in the same order into a second set of variables, excluding the least significant CNT register
3. Compare the first set with the second set. If they differ, start again from the top.
4. Use the first set of variables as the consistent chained counter value.

This sequence exploits the fact that reads are much faster than the least significant counter can ever overflow. The likelihood of encountering an overflow during the read sequence is therefore low. If an overflow occurs it will be detected and the next attempt would then succeed to read all values without any overflows in the chain. Unconditionallu retrying on any difference is a necessity though as, for example, interrupts could affect the timing and add unexpected delays.

由于多个 16b 寄存器无法自动读取,因此随时可能发生从一个值到下一个值的回绕,从而导致当前值的读出不一致。克服它的通常过程如下:

1. 读取第一组变量中链接的 CNT 寄存器的所有 16b 值,不包括最低有效的 CNT 寄存器
2. 以相同的顺序再次将所有 16b 值读取到第二组变量中,不包括最低有效的 CNT 寄存器
3. 比较第一组和第二组。如果不同,则从顶部重新开始。
4. 使用第一组变量作为一致的链式计数器值。

该序列利用了这样一个事实:读取速度比最低有效计数器溢出的速度要快得多。因此,在读取序列期间遇到溢出的可能性很低。如果发生溢出,它将被检测到,并且下一次尝试将成功读取所有值,而链中不会发生任何溢出。无条件地重试任何差异是必要的,例如,中断可能会影响计时并增加意外的延迟。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值