Jump to content

DosCloseMutexSem: Difference between revisions

From EDM2
Created page with "=== Syntax === rc = DosCloseMutexSem( ''phmtxSemaphore'' ); === Parameters === PHMTX ''phmtxSemaphore'' (input) This is a pointer to the HMTX that contains the handle to..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Syntax ===
== Syntax ==
 
DosCloseMutexSem( ''phmtxSemaphore'' )
rc = DosCloseMutexSem( ''phmtxSemaphore'' );
 


=== Parameters ===
=== Parameters ===
  PHMTX ''phmtxSemaphore'' (input)
;PHMTX ''phmtxSemaphore'' (input):This is a pointer to the HMTX that contains the handle to the semaphore to be closed.
 
This is a pointer to the HMTX that contains the handle to the semaphore to
be closed.
   
   
=== Returns ===
=== Returns ===
  APIRET rc
;APIRET rc:The following values can be returned:
The following values can be returned
  0 NO_ERROR             Semaphore closed successfully
   
  6 ERROR_INVALID_HANDLE Error, The value in ''phmtxSemaphore'' does not point to a valid semaphore
{| border="1"
301 ERROR_SEM_BUSY       Error, Another thread in this process is blocked on the semaphore
|-
|0
|NO_ERROR
|Semaphore closed successfully
|-
|6
|ERROR_INVALID_HANDLE
|Error, The value in ''phmtxSemaphore'' does not point to a valid semaphore
|-
|301
|ERROR_SEM_BUSY
|Error, Another thread in this process is blocked on the semaphore
|} 
=== Include Info ===
 
#define INCL_DOSSEMAPHORES
#include <os2.h>


=== Usage Explanation ===
=== Usage Explanation ===
 
DosCloseMutexSem decrements, by one (1), the usage count for the semaphore pointed to by ''phmtxSemaphore''. If the usage count goes to zero (0) then the semaphore is freed from the system.
DosCloseMutexSem decrements, by one (1), the usage count for the semaphore  
pointed to by ''phmtxSemaphore''. If the usage count goes to zero (0)  
then the semaphore is freed from the system.
 
* The usage count for private semaphores is always one (1) so all private semaphores will be freed on successful completion of this call.
* The usage count for private semaphores is always one (1) so all private semaphores will be freed on successful completion of this call.
* Shared (named or unnamed) semaphores may have usage counts greater than one (1), therefore they may or may not be freed from system resources on successful completion of DosCloseMutexSem.
* Shared (named or unnamed) semaphores may have usage counts greater than one (1), therefore they may or may not be freed from system resources on successful completion of DosCloseMutexSem.
=== Relevant Structures ===
=== Gotchas ===
   
   
=== Sample Code ===
=== Sample Code ===
<PRE>
<PRE>
#define INCL_DOSSEMAPHORES
#define INCL_DOSSEMAPHORES
#include  
#include <os2.h>


PHMTX phmtxMySemaphore; /* pointer to my semaphore handle */
PHMTX phmtxMySemaphore; /* pointer to my semaphore handle */
Line 67: Line 37:
}
}
</PRE>
</PRE>
=== See Also ===
=== See Also ===
[[OS2 API:CPI:DosCreateMutexSem|CPI:DosCreateMutexSem]], [[OS2 API:CPI:DosOpenMutexSem|CPI:DosOpenMutexSem]], [[OS2 API:CPI:DosQueryMutexSem|CPI:DosQueryMutexSem]], [[OS2 API:CPI:DosReleaseMutexSem|CPI:DosReleaseMutexSem]], [[OS2 API:CPI:DosRequestMutexSem|CPI:DosRequestMutexSem]]  
*[[DosCreateMutexSem]]
 
*[[DosOpenMutexSem]]
*[[DosQueryMutexSem]]
*[[DosReleaseMutexSem]]
*[[DosRequestMutexSem]]


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

Latest revision as of 20:36, 29 November 2019

Syntax

DosCloseMutexSem( phmtxSemaphore )

Parameters

PHMTX phmtxSemaphore (input)
This is a pointer to the HMTX that contains the handle to the semaphore to be closed.

Returns

APIRET rc
The following values can be returned:
  0 NO_ERROR             Semaphore closed successfully
  6 ERROR_INVALID_HANDLE Error, The value in phmtxSemaphore does not point to a valid semaphore
301 ERROR_SEM_BUSY       Error, Another thread in this process is blocked on the semaphore

Usage Explanation

DosCloseMutexSem decrements, by one (1), the usage count for the semaphore pointed to by phmtxSemaphore. If the usage count goes to zero (0) then the semaphore is freed from the system.

  • The usage count for private semaphores is always one (1) so all private semaphores will be freed on successful completion of this call.
  • Shared (named or unnamed) semaphores may have usage counts greater than one (1), therefore they may or may not be freed from system resources on successful completion of DosCloseMutexSem.

Sample Code

#define INCL_DOSSEMAPHORES
#include <os2.h>

PHMTX phmtxMySemaphore; /* pointer to my semaphore handle */

	/* a mutex semaphore is successfully created */
	/* its handle is placed in phmtxMySemaphore  */

	rc = DosCloseMutexSem(phmtxMySemaphore);

	if (rc != 0)
	{
	  /* We got an error to take care of. */
	}
	else
	{
	  /* The semaphore was successfully closed */
	}

See Also