[ Home | Alpha index | Topic index | Tutorials | Download | Feedback ]

The OS/2 API Project

DosCreateEventSem

[ Syntax | Params | Returns | Include | Usage | Structs | Gotchas | Code | Also ]

Syntax

rc = DosCreateEventSem( pszSemaphoreName, phevSemaphore, ulAttributeFlags, f32InitialState );

Parameters

PSZ pszSemaphoreName (input)
This is a pointer to the null-terminated string containing the semaphore name. Any named semaphore is considered shared. An unnamed semaphore will be created with pszSemaphoreName set to NULL. The name of a semaphore must be prefixed by \SEM32\, cannot be longer than 255 characters and must conform to the naming conventions of the file system.

PHEV phevSemaphore (output)
This is a pointer to the HEV that will get the handle to the new semaphore.

ULONG ulAttributeFlags (input)
This contains the attribute flags relevant to the creation of the semaphore. As of this writing only one value may be set for ulAttributeFlags, it is DC_SEM_SHARED. ulAttributeFlags is checked for this value only if pszSemaphoreName is NULL. If ulAttributeFlags equals DC_SEM_SHARED then the semaphore is considered an unnamed, shared semaphore.

BOOL32 f32InitialState (input)
This boolean flag marks the initial state of the semaphore.

Returns

APIRET rc
The following values can be returned
0NO_ERRORSemaphore created successfully
8ERROR_NOT_ENOUGH_MEMORYError, Memory limit has been exceeded
87ERROR_INVALID_PARAMETERError, Unrecognized parameter
123ERROR_INVALID_NAMEError, Name in pszSemaphoreName was rejected by file system
285ERROR_DUPLICATE_NAMEError, Name in pszSemaphoreName is in use
290ERROR_TOO_MANY_HANDLESError, System limit of 65536 semaphores has been exceeded

Include Info

#define INCL_DOSSEMAPHORES
#include <os2.h>

Usage Explanation

DosCreateEventSem creates a system event semaphore. The semaphore may be either private or shared and is accessable by all threads of the calling process.

Relevant Structures

Gotchas

Sample Code

#define INCL_DOSSEMAPHORES #include <os2.h> UCHAR SemName; /* Pointer to the Semaphore Name */ PHEV phevMySemaphore; /* pointer to my new semaphore handle */ ULONG ulAttribs= 0; /* Attribute flags, not used in this case */ BOOL32 f32Owned= TRUE; /* initial state of the semaphore, owned */ /* put the semaphore name in SemName */ strcpy(SemName,"\\SEM32\\MySem"); rc = DosCreateEventSem(SemName, phevMySemaphore, ulAttribs, f32Owned); if (rc != 0) { /* We got an error to take care of. */ } else { /* creation was successful */ /* The semaphore may be accessed via the phevMySemaphore handle */ }

See Also

DosCloseEventSem, DosOpenEventSem, DosPostEventSem DosQueryEventSem, DosResetEventSem DosWaitEventSem

Author

Joe Phillips - jaiger@eng2.uconn.edu

Additions

Last modified June 19/1996
Please send all errors, comments, and suggestions to: timur@vnet.ibm.com

The OS/2 API Project

DosCreateEventSem