Jump to content

DosReleaseMutexSem: Difference between revisions

From EDM2
Created page with "=== Syntax === rc = DosReleaseMutexSem( ''hmtxSemaphore'' ); === Parameters === HMTX ''hmtxSemaphore'' (input) The handle of the semaphore to be released. === Returns ..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Syntax ===
DosReleaseMutexSem releases ownership of mutex semaphore.
 
rc = DosReleaseMutexSem( ''hmtxSemaphore'' );


== Syntax ==
DosReleaseMutexSem( ''hmtxSemaphore'' );


=== Parameters ===
=== Parameters ===
Line 9: Line 9:
   
   
=== Returns ===
=== Returns ===
  APIRET rc
;APIRET rc:The following values can be returned
The following values can be returned
{|class="wikitable"
   
{| border="1"
|-
|0
|0
|NO_ERROR
|NO_ERROR
Line 25: Line 22:
|ERROR_NOT_OWNER
|ERROR_NOT_OWNER
|Error, The calling process does not currently own the semaphore
|Error, The calling process does not currently own the semaphore
|}
|}
=== Include Info ===
 
#define INCL_DOSSEMAPHORES
#include <os2.h>
 


=== Usage Explanation ===
=== Usage Explanation ===
It decrements, by one (1), the usage count of the mutex semaphore referred 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.


DosReleaseMutexSem releases ownership of  mutex semaphore.
The process calling DosReleaseMutexSem must first obtain access to the semaphore in question or ERROR_INVALID_HANDLE will be returned.
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 ===
=== Sample Code ===
<pre>
<pre>
#define INCL_DOSSEMAPHORES
#define INCL_DOSSEMAPHORES
#include  
#include <os2.h>


HMTX  hmtxMySemaphore;    /* MySemaphore handle */
HMTX  hmtxMySemaphore;    /* MySemaphore handle */
Line 71: Line 51:
}
}
</pre>
</pre>
=== See Also ===
=== See Also ===
[[OS2 API:CPI:DosCloseMutexSem|CPI:DosCloseMutexSem]],
*[[DosCloseMutexSem]]
[[OS2 API:CPI:DosCreateMutexSem|CPI:DosCreateMutexSem]],
*[[DosCreateMutexSem]]
[[OS2 API:CPI:DosOpenMutexSem|CPI:DosOpenMutexSem]],
*[[DosOpenMutexSem]]
[[OS2 API:CPI:DosQueryMutexSem|CPI:DosQueryMutexSem]],
*[[DosQueryMutexSem]]
[[OS2 API:CPI:DosRequestMutexSem|CPI:DosRequestMutexSem]]  
*[[DosRequestMutexSem]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 12:02, 12 October 2018

DosReleaseMutexSem releases ownership of mutex semaphore.

Syntax

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

Usage Explanation

It decrements, by one (1), the usage count of the mutex semaphore referred 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.

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 <os2.h>

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