simavr: Improved accuracy of sleep durations
authorJakob Gruber <jakob.gruber@gmail.com>
Thu, 19 Jul 2012 21:37:02 +0000 (23:37 +0200)
committerJakob Gruber <jakob.gruber@gmail.com>
Thu, 19 Jul 2012 21:46:19 +0000 (23:46 +0200)
commit8e195b43da0db4f2e9bd6f56cf68ba91b57676e2
treebcb51641411b33f429a07e1923026f20cc8ffb8f
parentde9f70375c1967c9d24f9181b66bbb949afee47f
simavr: Improved accuracy of sleep durations

This commit solves (or at least improves) an issue that occurs when
short sleep times are requested in avr_callback_sleep_*. The operating
system cannot accurately handle short sleep requests, and sending many
short requests takes significantly longer than requesting the equivalent
time in longer bursts. This can be observed by running the board_hd77480
example - the counter is much slower when vcd recording is turned on
(= short sleep requests) than when it is turned off (= long sleep
requests).

We improve this situation by accumulating sleep requests until a certain
minimum count of pending usecs is reached which can be handled somewhat
accurately (200 microseconds worked well for me).
simavr/sim/sim_avr.c
simavr/sim/sim_avr.h