Senen,
Did you mean 35 Mb or 350 Mb? The latter sounds like you've got really heavy MinLogon image. In fact, if network is not required,
you can get a working Minlogon image with CMD Shell within 20-30 Mb.
Just in case, fire up a tool like DiskMon (sysinternals.com) and check if there is any disk level activities going on in your
system.
Since you are running the thread in time critical priority I wouldn't expect the 10-15 jitter from the Sleep(1) call unless there
are other time critical threads are running in the system at the same time. Although it would be hard to believe so on Minlogon
image.
Anyway, you may want to explore the system clock interval with NtQueryTimerResolution undocumented API exported by NTDLL.dll. You
can also change the interval with NtSetTimerResolution function. More info about he functions you will find on Mark's page here:
http://www.microsoft.com/technet/sysinternals/information/HighResolutionTimers.mspx. Try the ClockRes to see what the system tick is
set to on your device:
http://www.microsoft.com/technet/sysinternals/utilities/ClockRes.mspx. It is typically around 15.625ms on x86
PC.
Or, even easier if you don't want to mess with this code in your app, use the TimerResolution app from
http://users.tpg.com.au/lucash. Really nice app but prohibits the free commercial use so you, if this approach taken, will end up
calling the NtQueryTimerResolution in your own code anyway.
You may also want to take a look at the Multimedia timers. Specifically, by querying to timeGetDevCaps API
(
http://msdn.microsoft.com/library/d.../en-us/multimed/htm/_win32_timegetdevcaps.asp) you can determine the
supported minimum timer resolution. Calling the timeBeginPeriod API
(
http://msdn.microsoft.com/library/d...en-us/multimed/htm/_win32_timebeginperiod.asp) you can set the timer
resolution to its minimum and thus increase the accuracy of the sleep interval.
I also hope that you setting THREAD_PRIORITY_TIME_CRITICAL priority level within REALTIME_PRIORITY_CLASS priority class (if not,
please take a look at SetPriorityClass API
http://msdn2.microsoft.com/en-us/library/ms686219.aspx).
Also, disable system thread priority boost for your thread - SetThreadPriorityBoost
(
http://msdn2.microsoft.com/en-us/library/ms686280.aspx) and SetProcessPriorityBoost functions - to make it more deterministic.