I am using mingw to compile some code that has been developed on Linux. As it turns out, mutexes that have been set to make critical sections thread safe, do no work on win32.
The code works fine on Linux, but on win32 the exact same code completely ignores the mutex locks.
It can be easily reproduced with the code attached.
A thread is started that continually locks and unlocks a mutex, with a few seconds gap in between.
In the mean time the main thread continually tries to acquire a lock on the same mutex.
A variable keeps track of whether the mutex is locked or not. Whenever it is locked by one thread when the other thread locks the same mutex, it demonstrates that the mutex has failed to block the second thread.
The same code works as expected when I use a mutex from another library (which can be found on http://www.alhem.net/Sockets/\). This can be verified by undefining USE_CCGNU2.
I can be contacted on firstname.lastname@example.org
Log in to post a comment.