Jump to content

DosCloseEventSem: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Syntax ===
== Syntax ==
 
DosCloseEventSem( ''hevSemaphore'' )
rc = DosCloseEventSem( ''hevSemaphore'' );
 


=== Parameters ===
=== Parameters ===
  HEV ''hevSemaphore'' (input)
HEV ''hevSemaphore'' (input)
This is a handle to the event semaphore (HEV) to
This is a handle to the event semaphore (HEV) to be closed.
be closed.
   
   
=== 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 26: Line 20:
|ERROR_SEM_BUSY
|ERROR_SEM_BUSY
|Error, Another thread in this process is blocked on the semaphore
|Error, Another thread in this process is blocked on the semaphore
|}
|}
=== Include Info ===
 
#define INCL_DOSSEMAPHORES
#include <os2.h>


=== Usage Explanation ===
=== Usage Explanation ===
 
DosCloseEventSem decrements, by one (1), the usage count for the semaphore specified by the handle ''hevSemaphore''. If the usage count goes to zero (0) then the semaphore is freed from the system.
DosCloseEventSem decrements, by one (1), the usage count for the semaphore  
specified by the handle ''hevSemaphore''. 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 DosCloseEventSem.
* 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 DosCloseEventSem.
   
   
=== Relevant Structures ===
==Sample Code==
<PRE>
=== Gotchas ===
=== Sample Code ===
#define INCL_DOSSEMAPHORES
#define INCL_DOSSEMAPHORES
#include  
#include <os2.h>


HEV hevMySemaphore; /* pointer to my semaphore handle */
HEV hevMySemaphore; /* pointer to my semaphore handle */
Line 65: Line 47:
  /* The semaphore was successfully closed */
  /* The semaphore was successfully closed */
}
}
</PRE>
=== See Also ===
 
[[OS2 API:CPI:DosCreateEventSem|CPI:DosCreateEventSem]], [[OS2 API:CPI:DosOpenEventSem|CPI:DosOpenEventSem]], [[OS2 API:CPI:DosPostEventSem|CPI:DosPostEventSem]], [[OS2 API:CPI:DosQueryEventSem|CPI:DosQueryEventSem]], [[OS2 API:CPI:DosResetEventSem|CPI:DosResetEventSem]][[OS2 API:CPI:DosWaitEventSem|CPI:DosWaitEventSem]]  
==See Also==
*[[DosCreateEventSem]]
*[[DosOpenEventSem]]
*[[DosPostEventSem]]
*[[DosQueryEventSem]]
*[[DosResetEventSem]]
*[[DosWaitEventSem]]  


[[Category:The OS2 API Project]]
[[Category:Dos]]

Latest revision as of 11:18, 12 October 2018

Syntax

DosCloseEventSem( hevSemaphore )

Parameters

HEV hevSemaphore (input)

This is a handle to the event semaphore (HEV) 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 hevSemaphore does not point to a valid semaphore
301 ERROR_SEM_BUSY Error, Another thread in this process is blocked on the semaphore

Usage Explanation

DosCloseEventSem decrements, by one (1), the usage count for the semaphore specified by the handle hevSemaphore. 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 DosCloseEventSem.

Sample Code

#define INCL_DOSSEMAPHORES
#include <os2.h>

HEV hevMySemaphore; /* pointer to my semaphore handle */

	/* an event semaphore is successfully created */
	/* its handle is placed in hevMySemaphore  */

	rc = DosCloseEventSem(hevMySemaphore);

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

See Also