DosCreateMutexSem

DosCreateMutexSem creates a system mutual exclusion (mutex) semaphore. The semaphore may be either private or shared and is accessible by all threads of the calling process.

Syntax
rc = DosCreateMutexSem( pszSemaphoreName,                         phmtxSemaphore,                          ulAttributeFlags,                          f32InitialState );

Parameters
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. 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.
 * 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
 * PHMTX phmtxSemaphore (output):This is a pointer to the HMTX 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
 * BOOL32 f32InitialState (input):This boolean flag marks the initial state of the semaphore.
 * Setting TRUE (0x00000001) makes the initial state of the semaphore owned and threads waiting on the semaphore will block.
 * Setting FALSE (0x00000000) makes the initial state of the semaphore unowned and threads waiting on the semaphore will not block.

Returns
APIRET rc The following values can be returned

Sample Code

 * 1) define INCL_DOSSEMAPHORES
 * 2) include 

UCHAR SemName;         /* Pointer to the Semaphore Name */ PHMTX phmtxMySemaphore; /* 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 = DosCreateMutexSem(SemName, phmtxMySemaphore, ulAttribs, f32Owned);

if (rc != 0) {	 /* We got an error to take care of. */	}	else {	 /* creation was successful */ /* The semaphore may be accessed via the phmtxMySemaphore handle */ } 