concern about millis()

hi!

what if the timer interrupt (SIGNAL(SIG_OVERFLOW0)) happens while i call millis() and a byte (of volatile unsigned long timer0_overflow_count) overflows, that is already used in millis()'s computation?

e. g.
timer0_overflow_count=255
millis() call happens
least significant byte is read and multiplied with 2^14
SIG_OVERFLOW0 happens
now: timer0_overflow_count=256
now the second least significant byte is read and the result looks like timer0_overflow_count was (255+256)

is it a good idea to write a "safe_millis()",
that has a "cli()" in the beginning, and
that restores registers in the end?

bye
arne

It is fixed in 0012.

oh - ok
thx

i just checked it...
looks good :slight_smile:

-arne