Jump to content

DosOpenMuxWaitSem

From EDM2
Revision as of 00:32, 17 May 2016 by Martini (talk | contribs) (Created page with "=== Syntax === rc = DosOpenMuxWaitSem( ''pszSemaphoreName'', ''phmuxSemaphore'' ); === Parameters === PSZ ''pszSemaphoreName'' (input) This is a ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax

rc = DosOpenMuxWaitSem( pszSemaphoreName,
                        phmuxSemaphore );


Parameters

PSZ pszSemaphoreName (input)

This is a pointer to NULL terminated string containing the name of the shared MuxWait semaphore to access. If this value is NULL then the semaphore to access is specified in phmuxSemaphore.

PHMUX phmuxSemaphore (input/output)

For input, this value is a pointer to the MuxWait semaphore handle that should be openned if pszSemaphoreName is NULL. If pszSemaphoreName is not NULL then this value must be NULL on input. For output, this is a pointer to the MuxWait semaphore handle (HMUX) to the openned semaphore.


Returns

 APIRET rc

The following values can be returned

0 NO_ERROR Semaphore

opened successfully

6 ERROR_INVALID_HANDLE Error, The value in phmuxSemaphore does not point to a valid

semaphore

8 ERROR_NOT_ENOUGH_MEMORY Error, The system memory limit has been exceeded
87 ERROR_INVALID_PARAMETER Error, One or more parameters is not recognized, See parameters above,

Both pszSemaphoreName and phmuxSemaphore may be NULL

105 ERROR_SEM_OWNER_DIED Error, The owner of the semaphore has died without freeing the

semaphore

123 ERROR_INVALID_NAME Error, The name pointed to by pszSemaphoreName has been rejected

by the file system

187 ERROR_SEM_NOT_FOUND Error, There is no semaphore with the name in

pszSemaphoreName

291 ERROR_TOO_MANY_OPENS Error, The usage count for the semaphore in question has exceeded the

system limit of 65535

Include Info

#define INCL_DOSSEMAPHORES
#include <os2.h>


Usage Explanation

DosOpenMuxWaitSem gains access to a shared MuxWait semaphore.

Relevant Structures

Gotchas

The process that created the MuxWait semaphore does not need to call this. The process wishing to use this function must first have gained access to all semaphores in the muxwait list of the MuxWait semaphore to which access is intended or ERROR_INVALID_HANDLE will be returned.


Sample Code

#define INCL_DOSSEMAPHORES
#include 

UCHAR SemName[15];
PMUX  phmuxMySemaphore= NULL; /* pointer to my semaphore handle */

	/* a shared MuxWiat semaphore is successfully created in another process */
	/* its name happens to be \SEM32\MySem */

	strcpy(SemName,"\\SEM32\\MySem");

	rc = DosOpenMuxWaitSem(SemName, phmuxMySemaphore);

	if (rc != 0)
	{
	  /* We got an error to take care of. */
	}

See Also

DosAddMuxWaitSem, DosCloseMuxWaitSem, DosCreateMuxWaitSem, DosDeleteMuxWaitSem, DosQueryMuxWaitSem, DosWaitMuxWaitSem