Troubleshooting
Problem
When implementing millisecond timers on Microsoft® Windows® CE targets with GetSystemTime(), Windows CE targets only appear to have a timer resolution of 1 second.
Cause
There is a known issue that on some Windows CE targets, GetSystemTime() doesn't return milliseconds. The GetSystemTime() should return a wMilliseconds value but instead returns "0".
The IBM® Rational® Rose RealTime® services library call, "getclock", uses GetSystemTime() and will be impacted on these targets, causing the resolution of timers to be 1 second.
Resolving The Problem
If millisecond timers are required, then for a workaround, the getclock.cc function could be altered to use GetTickCount().
For example: $RTS_HOME\src\target\WINCE\RTTimerspec\getclock.cc
#include#include #include void RTTimespec::getclock( RTTimespec & ts ) { DWORD ticks = GetTickCount(); ts.tv_sec = ( (long)ticks / 1000L ); ts.tv_nsec = 1000000L * ( (long)ticks % 1000L ); }
Note: That GetTickCount() is the system uptime and will wrap around after 49.7 days. For systems that are up for longer, then a combination of GetSystemTime() and GetTickCount() could be used to gain the desired length and resolution of clock time. Any implementation, including the above code workaround, will be system dependant and the responsibility of the customer to manage.
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21131611