UsingThreads:SynchronizationTimings: Difference between revisions
Appearance
Myrkraverk (talk | contribs) Draft saved |
(No difference)
|
Revision as of 20:40, 8 November 2007
All thread related material I've come across the 'net that mention the OS/2 API DosEnterCritSec() is slow and should not be used. Here I present my own timings of it, compared to DosRequestMutexSem().
The Timing Method
First, let me introduce the method I used for timing the system calls: DosTmrQueryTime(). This system call returns a snapshot of the high resolution timer. This is a 64 bit value, directly from the high resolution timer device [or, so I believe]. It is returned in a DWORD structure, and I use the following method to get it into OpenWatcoms 64 bit long long, given a DWORD time value:
unsigned long long int timer_snapshot = ( time.ulHi << 32 ) | time.ulLo;
To time a function, a snapshot is taken just before, and just after the function call, like so:
DosTmrQueryTime( &start ); DosEnterCritSec(); DosTmrQueryTime( &end );