Querying a Muxwait Semaphore

Processes use DosQueryMuxWaitSem to obtain the semaph ore records for each of the semaphores included in the muxwait semaphore.

Any thread in the process that created a muxwait semaphore can obtain information about the semaphores in the muxwait list by calling DosQueryMuxWaitSem. Threads in other processes can also use this function, but they must first gain access to the semaphore by calling DosOpenMuxWaitSem.

An application must provide this function with an array in which to store the semaphore records. If the array is not large enough to hold all of the semaphore records that are in the muxwait list, then ERROR_PARAM_TOO_SMALL is returned, and the record-counting parameter of DosQueryMuxWaitSem will contain the number of semaphore records that are in the muxwait list. The calling thread can then allocate the correct amount of space and call DosQueryMuxWaitSem again with the correct amount of space for the list of records.

If the owner of any mutex semaphore in the muxwait-semaphore list has ended without releasing the semaphore, the records of all the semaphores in the list are still returned, but DosQueryMuxWaitSem also returns ERROR_SEM_OWNER_DIED. The calling thread can call DosQueryMutexSem for each mutex semaphore in the muxwait-semaphore list so that it can determine which semaphores are in the Owner Died state. The process can then close the unowned mutex semaphores.

Each mutex semaphore that returns ERROR_SEM_OWNER_DIED from the query should be closed by calling DosCloseMutexSem. Also, because semaphore handles can be reused, the mutex semaphores that are closed should be deleted from the muxwait-semaphore list by calling DosDeleteMuxWaitSem.

If the specified muxwait semaphore does not exist, ERROR_INVALID_HANDLE is returned.


[Back: Deleting a Semaphore from a Muxwait List]
[Next: Timers]