UsingThreads:SynchronizationTimings
Appearance
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 );