19.10.2015 23:01, Dmitry Osipenko пишет:
What about the following:
Add additional ptimer struct member, say "limit_corrected", to check whether the
limit was corrected or not.
ptimer_set_limit(ptimer_state *s, uint64_t limit, int reload)
{
.limit_corrected = 0;
// on the limit correction:
.limit_corrected = (limit == 0) ? 1 : 2;
limit = 10000 / s->period;
}
ptimer_get_count()
{
if (enabled) {
if (expired || .limit_corrected == 1) {
counter = 0;
} else if (.limit_corrected == 2) {
counter = 1;
} else {
// do the counter calculations ...
}
}
}
and clear .limit_corrected on the one-shot timer start. That would bump ptimer
VMSD version, but keep .minimum_version_id.
However, that would break set_counter(). Also limit should be corrected on
period / freq change. I'll work more on it.
--
Dmitry