[En-Nut-Discussion] systime limit reduces valid uptime to 49 days

Michael Müller mmueller at cs.uni-kassel.de
Tue Nov 6 17:10:41 CET 2007


Hi,

I was quite shocked when looking at the code parts calculating the 
system time. If I did not calculate complete rubbish it seems as if 
there is a time overflow after 49 days! At least using Ethernut 1.3 with 
32bit long variables. The comment at the head of NutGetMillis(void) 
function tells about a maximum systime of 8 years. It seems to refer to 
the old systick of 62ms instead of the current default value of 1ms.

timer.c
=======

  u_long NutGetTickCount(void);

  ...

  u_long NutGetSeconds(void)
{
     return NutGetTickCount() / NutGetTickClock();
}

ostimer.c
=========
u_long NutGetTickClock(void)
{
     return NUT_TICK_FREQ; /* = 1024 */
}

This reduces the maximum count of seconds to

2^32 / 1000 [s] = 49days!

Are there any suggestions how to handle this?
- Change the systick to 62ms again (was the reason just more precision 
for the "user application" or was it useful / necessary for the OS, too?) ?
- Increase the tick variable of NutOS to a 64bit type
(unsigned long long)?


Best regards
  Michael





More information about the En-Nut-Discussion mailing list