Mutexes multiacquiring in Win32

Mutexes multiacquiring in Win32

Post by Vladimir F » Thu, 16 Mar 2006 21:27:40


Hello, All

MSDN wrote about WaitForMultipleObjects:
Before returning, a wait function modifies the state of some types of
synchronization objects. Modification occurs only for the object or
objects whose signaled state caused the function to return. When
fWaitAll is FALSE, and multiple objects are in the signaled state, the
function chooses one of the objects to satisfy the wait; the states of
the objects not selected are unaffected.
So, there is one question: is WaitForMultipleObjects do modification
of synchronization objects atomically or not? I mean can this code
cause dead-lock:

Thread 1:
{
vector<HANDLE> vec;
vec.push_back( _mutex1 );
vec.push_back( _mutex2 );
WaitForMultipleObjects(2, &vec.front(), TRUE, INFINITE);
}

Thread 2:

{
vector<HANDLE> vec;
vec.push_back( _mutex2 );
vec.push_back( _mutex1 );
WaitForMultipleObjects(2, &vec.front(), TRUE, INFINITE);
}

Does one of those threads atomicaly lock both mutexes?
 
 
 

1. win32 kernel-mode asymmetric rw-mutex support...

2. Win32: Can a lockup ever happen on a Mutex ?

Hi,

I have 4 application sharing a piece of memory, protected by a named Mutex.

If one application crashes while having aqquired the Mutex, then it should
release it right ? and if 4 applications has aqquired a handle for the named
Mutex, then all 4 has to quit before the Mutex is removed from the system
right ?

Doesnt this mean that a named Mutex never can go into a deadlock ? the only
problem there could be with a mutex would be if for some reason the code
(programatically) forgets to release the mutex again right ?

3. pgsql-server: > win32 doesn't support a static initializer for mutexes,

4. [PATCH] fix libpq mutex initialization for multithreaded win32 libs

5. pgsql-server: win32 doesn't support a static initializer for mutexes,

6. [ANN] win32-mutex 0.1.0

7. how to avoid pulling in Win32 include "world" for mutex

8. Are Plug-ins for WMP 10 supported by WinCE PPC as well as Win32?

9. Win32: Possible to use Python to create Snap-Ins for MMC?

10. Mutex - Access denied err when creating mutex from a window servic

11. Can't call Mutex.WaitOne() again after Mutex.ReleaseMutex()

12. Difference between mutex.mutex and threading.Lock

13. Mutex error -- Cannot create mutex

14. Win32.SillyDI.FG, Win32.BETTInet,HTML.MHTMLREDIR/EXPLOIT,WIN32.SILLYDL.HQ