Mutex

Hi all,

If calls to Mutex functions are made quickly in a multri-
threaded program in windows 2000 sp1 eventually (and not always
at the same point) the Mutex_Lock function never returns. The
exact same *.EXE run under windows NT works fine without
changes.

If INFINITE is replaced by a time (45ms in this case), the
program works under Win200 sp1 and Win NT but this is not an
acceptable solution for the release version of the software.

The calls tend to be:-
Mutex_Lock (pEntity->pControls->nMutex);
// Do something to or with pEntity->EntityData
Mutex_Unlock (pEntity->pControls->nMutex);

“Do something” may only be a single x = y; command or may be a
complicated function call. Several threads have change access to
the same data areas.

Note that we are using MSVC 6.0-SP3 and not SP4 because of the
Multi-tasking crash-at-startup problems introduced in SP4. If
there is a work around for this problem, we would like to hear
it too.

bool Mutex_Lock (long hMutex)
{
if (WaitForSingleObject ((HANDLE) hMutex, INFINITE) ==
WAIT_FAILED)
{
return false;
}
else
{
return true;
}
}

bool Mutex_Unlock (long hMutex)
{
if (ReleaseMutex ((HANDLE) hMutex) == 0)
{
return false;
}
else
{
return true;
}
}
Thanks
Robert
Fernando


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com