Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Tick accuracy
From: Linus Nielsen Feltzing (linus_at_haxx.se)
Date: 2003-05-01


Johan Vromans wrote:
> Just wondering...
>
> apps/screens.c, usb_screen:
>
> while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
> if(usb_inserted()) {
> status_draw(false);
> }
> }
>
> This would call status_draw() once every HZ (100) ticks.

Correct.

> apps/status.c, status_draw:
>
> if(TIME_AFTER(current_tick, switch_tick)) {
> battery_charge_step=(battery_charge_step+1)%4;
> switch_tick = current_tick + HZ;
> }
>
> Assuming it is called on tick 0, switch_tick is set to 100.
> The next time it is called, current_tick is 100 so battery_charge_step
> is not changed.
> The next time it is called, current_tick is 200 so this code is
> executed, and switch_tick is set to 300.
> And so on.
>
> In other words, the code that is assumed to be executed every 100
> ticks is only executed every 200 ticks.

Unless current_tick advances one tick during the execution of the code.

> Is that correct? Am I overlooking something?

I think you have found a potential bug in the code.

> Peculiar thing is I do not _see_ this happening in the pre-build 2.0
> version, but I _do_ see it in the CVS versions I build myself.

That may be because of different optimization, or different phases of
the moon. .-)

/Linus



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa