gw_logo_08.gif (1982 bytes) 
Last edit: 05-03-17 Graham Wideman
Data Acquisition
SkedGran: Quick and dirty look at scheduler granularity
Article created: 99-06-16

Recently I needed to find out The Truth about NT and Win95 Task Scheduler granularity.   This little demo app is the result.

Basically, you get to click one of two buttons, and after a brief pause you get a table of values showing how long a thread actually slept when it asked for a sleep of the indicated millisecs.

Screen Shot -- Win NT 4 WS

Normal timing.

Note the Sleep ms column shows the value used in the Sleep(N) call, while the Actual colum shows the millisecs that the sleep actually consumed. As you can see, under normal timing, the sleeps come in multiples of 10 millisecs. 

skedgrannorm.gif (15913 bytes)

The Begin, End and Dur columns are in the units used by the QueryPerformanceCounter function.

Hi Res Timing

The following shot shows the results while the scheduler is set to highest possible resolution, using the timeBeginPeriod function. Now Sleeps are controlled to one millisec.

skedgranhires.gif (16097 bytes)


You can download the app here:  Delphi source is included, which would also be handy for C/C++ programmers as the API calls are the same.

Installation -- just copy it somewhere and unzip. Then you can run the exe, or view the source.

Operation -- Move the mouse over one of the buttons and .... heh heh, just kidding.


Though I didn't actually link to it, had it not been for Tom Leathley (Ryle Design) providing source with his ExacTicks timing library, I would never have got much traction on Window timing issues.  

[Up to:  Data Acquisition Topics]

Go to:  gw_logo_08.gif (1982 bytes)