Why uptime on WP7 cannot be longer than 24.9 days?

Written by  on January 24, 2012 

This morning I saw in System View on my Samsung Omnia 7 that uptime is “more than 24.9 days”, and boot time is “earlier than 30-Dec-11 13:07:24”. At first I was amazed, how can it be “earlier than”, and how that reference in time is not fixed (it was 29-Dec yesterday). Then I realized that phone does not “remember” its time of boot, but has some sort of incrementing register for counting uptime, and it hits its limit on 24.9 days. It would be interesting for how long this phone can work without reboot, as it seems very stable, but it seems that cannot be known without manual recording of boot time Disappointed smile.

I did some calculations, and it seems that phone is using SIGNED int as register value which counts number of MILISECONDS since boot. As 25 days has about 2’160’000’000 milliseconds, and 2^31 is 2’147’483’648, it starts to seem logical where did number 24.9 days came from Nerd smile. It is logical that boot time itself is not recorded, as there it would be a possibility of reporting “fake” uptimes by setting the clock on the phone. However, in my opinion, method used is also not optimal.

So, what could be better here? Light bulb

- For start, it could be unsigned int, so the OS would be able to keep track for more than 49 days of uptime.
- It could also count seconds instead of milliseconds, that would make possible to count more than 1300 years of uptime Smile, or if for some reason needs to keep milliseconds (i.e. does not want to break all existing functionalities?), unsigned long (int64) could be used (although I don’t remember if it is available in WP7), to give overkilling amount of almost 585 millions of years Hot smile.

All this considered, it seems that 49 days would be enough, change would not break anything, and it requires changing only one variable declaration.

Category : .NETComputersProgrammingSmartphones

Tags :

  • David Bakin

    History repeats itself. Windows 95/98 had this problem too, only after 49.7 days. They used an unsigned value to hold milliseconds since boot.

    See, e.g., http://support.microsoft.com/kb/216641 and http://www.youtube.com/watch?v=OMEL3rBqtEM

    At least your phone didn’t crash! How long did it finally stay up?

  • obrad

    Interesting :)

    I don’t know how long it stayed up, because counter did not work :)
    But phone itself worked without problems, which is much better than this with win 98.

%d bloggers like this: