Christian Wallukat wrote:
Do you have another idea ?
Maybe ...
BTW: Can you explain what a Sleep(0) does ?
The idea is to have the thread requesting the lock to briefly yield the CPU (at least the remainder of the current time quantum). Some other thread that might already have the lock acquired gets a change to finish it's work and release the lock.
In your original post - you mentioned 200 threads. Are these threads all fighting for the same critical section?
Perhaps you could break up the main data structure into smaller pieces - each with it's own critical section (finer granularity of locking).
Instead of 199 threads waiting on 1 thread (that has the lock) you have 180 threads waiting on 20 others to release some lock (but each of the 20 is able to continue unimpeded).
-rick