Windows CE – GetTickCount – Problems ?

Jack W. Crenshaw has written an article for which is titled “Time to re-evaluate Windows CE?” – Jack looks at a specific API, GetTickCount( ); which returns an unsigned int, this value is incremented every millisecond. The unsigned int can stand to be incremented 4,294,967,296 times before it rolls back around to zero. That's equivalent to:

4,294,967.296 s = 71582.78827 min = 1193.046471 hr = 49.7103 days

The article asserts that GetTickCount could be the cause of operating system crashes, which in turn could cause problems for an embedded system based on Windows CE.
I think this issue is pretty well documented.  The general Win32 documentation is pretty clear about the use of GetTickCount, and the Windows CE 5.0 documentation also contains information about the rollover.  Windows CE does have API’s like SystemTime which can be used as a absolute value as well as the SystemTimeToFileTime() apis if you want to convert it to a 64 bit value.
Information about GetTickCount( ) can be found in the Microsoft Product Support Knowledge Base 
Interestingly, if you build a debug Windows CE operating system image the return value for GetTickCount( ) is set to roll over within the first two minutes of running the operating system, this of course gives you, the developer, the chance to debug your applicaiton on the operating system under the rollover condition (which is much better than waiting 49.7 days!).
Is this an issue – potentially, yes, this could be as much of an issue as not testing the return values from memory allocations, getting a null pointer and trying to use the memory – if you understand the issue, and test for the condition then you don’t have a problem.
– Mike

Comments (2)

  1. Mike Dimmick says:

    There was a load of noise last year about some air traffic control systems implemented on Windows NT (not sure if Embedded or not) which failed after running continuously for 49.7 days. Yup, they’d not allowed for rollover.

    The OS itself hasn’t had problems since Windows 95. Our main file and print server is currently running flawlessly at 74 days uptime. You just have to know to handle the overflow case.

    It’s important to note that the tick timer only runs when the system is powered – it does not run when a CE device is suspended, for example. This is different from a ‘wall clock’ timer which does. Sometimes it’s necessary to distinguish between the two.

  2. I was surprised and dismayed to read a recent article in Embedded Systems Programming (…

Skip to main content