Link to home
Start Free TrialLog in
Avatar of hk895
hk895

asked on

Windows System Tick Time Resolution - Networking Select() loop

Hello,

Here is our problem. If I am wrong in any place please correct me. The whole context I am discussing here is with respect to Windows XP Professional Operating System on intel’s Pentium 4 processor.

The basic problem is that we are using a select() command and waiting on a set of socket fd’s. We need to wait in that select loop for just 10ms and after that we should come out of select() and send those packets from the FDSET list. What we inferred was, even if we give 10ms (4th parameter to select()) we are coming out of select only after 16ms. I believe its because the minimum resolution of the system tick time is 16ms in my system.

I read on MSDN documentation that the minimum system tick time for ( http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/windows_time.asp )
The system timer runs at approximately 10ms.
Windows Me/98/95:  The system timer runs at approximately 55ms.
Windows NT 3.1:  The system timer runs at approximately 16ms.

I am using the tick count to see the minimum system tick resolution, I use gettickcount() to get the tick count at that moment. (Output is directed to file to reduce the buffering overhead). In spite of many approaches to attain that 10ms resolution, I am unable to attain that and I see the minimum difference between two tick counts is 15ms (and often 16ms).

My output of gettickcount()

628324390
628324406     dif=16
628324421     dif=15
628324421     dif=0
628324437     dif=16
628324453     dif=16
628324453     dif=0
628324468     dif=15
628324468     dif=0
628324484     dif=16
\\ (repeats the same way)

Approaches:
1. Mere gettickcount(), called in loop.
2. Used Multimedia Timer to invoke gettickcount() after every 10ms (any time less than 16ms). Used timeBeginPeriod() to set the resolution to be 1ms. timeSetEvent(), timeKillEvent(),timeEndPeriod().
3. Used CreateWaitableTimer(), SetWaitableTimer() approach as well
4. Used the real-time option using setclasspriority(), used real-time priority
5. Tried using this macro as well #define _WIN32_WINNT 0x0401
6. I even investigated on Windows registry, to check if I can modify some data to change the system tick time, but of no use.

Haven’t used the high precision timer and settimer() stuff yet. Not sure how far its going to be helpful when all the above cases have failed to.  But I see in the output of stefan (please see the previous messages) the resoultion of tick count < 16ms. Stefan, can you please tell me what's you OS Wondering, Is that because of settimer() or is that because of you OS that you were able to get that resolution.

Wondering if I switch to Enterprice flavor, will it help? Because I heard that Enterprice version will have less time slice. If its possible to change the system tick time to 10ms in Windows XP pro, please let me know how to do that. Or you can directly address the problem, i.e how I can come out of select() loop after 10ms.

If I won’t be able to change this resolution of system tick time, please let me know by what means I can come out of select() loop after 10ms. Also if I can change the resolution of tick time in other windows and not in this, please let me know those OS.


Thanks in advance for the help. Sorry for the long mail (want to be as clear as possible)

With regards,
Karthik
ASKER CERTIFIED SOLUTION
Avatar of mxjijo
mxjijo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial