Jump to content

DosReleaseMutexSem

From EDM2
Revision as of 05:08, 17 May 2016 by Martini (talk | contribs) (Created page with "=== Syntax === rc = DosReleaseMutexSem( ''hmtxSemaphore'' ); === Parameters === HMTX ''hmtxSemaphore'' (input) The handle of the semaphore to be released. === Returns ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax

rc = DosReleaseMutexSem( hmtxSemaphore );


Parameters

 HMTX hmtxSemaphore (input)

The handle of the semaphore to be released.

Returns

 APIRET rc

The following values can be returned

0 NO_ERROR Semaphore released successfully
6 ERROR_INVALID_HANDLE Error, The value in phmtxSemaphore does not point to a valid semaphore, The calling process must first have access to the semaphore in question
288 ERROR_NOT_OWNER Error, The calling process does not currently own the semaphore

Include Info

#define INCL_DOSSEMAPHORES
#include <os2.h>


Usage Explanation

DosReleaseMutexSem releases ownership of mutex semaphore. It decrements, by one (1), the usage count of the mutex semaphore refered to by hmtxSemaphore. If the usage count for the mutex semaphore goes to zero (0), ownership of the semaphore will be passed on to another thread that has been blocked for requesting it.


Relevant Structures

Gotchas

The process calling DosReleaseMutexSem must first obtain access to the semaphore in question or ERROR_INVALID_HANDLE will be returned.


Sample Code

#define INCL_DOSSEMAPHORES
#include 

HMTX  hmtxMySemaphore;     /* MySemaphore handle */

	/* access is gained to the semaphore in question */
	/* either by DosCreateMutexSem ... */
	/* ... or by DosOpenMutexSem */
	/* its handle is placed in hmtxMySemaphore */

	/* process becomes owner of semaphore */
	/* by way of successful call to DosRequestMutexSem */

	rc = DosReleaseMutexSem(hmtxMySemaphore);

	if (rc != 0)
	{
	  /* We got an error to take care of. */
	}

See Also

CPI:DosCloseMutexSem, CPI:DosCreateMutexSem, CPI:DosOpenMutexSem, CPI:DosQueryMutexSem, CPI:DosRequestMutexSem