pr_opensemaphore.rst (1317B)
1 PR_OpenSemaphore 2 ================ 3 4 Creates or opens a named semaphore with the specified name. 5 6 7 Syntax 8 ------ 9 10 .. code:: 11 12 #include <pripcsem.h> 13 14 #define PR_SEM_CREATE 0x1 /* create if not exist */ 15 16 #define PR_SEM_EXCL 0x2 /* fail if already exists */ 17 18 NSPR_API(PRSem *) PR_OpenSemaphore( 19 const char *name, 20 PRIntn flags, 21 PRIntn mode, 22 PRUintn value 23 ); 24 25 26 Parameters 27 ~~~~~~~~~~ 28 29 The function has the following parameters: 30 31 ``name`` 32 The name to be given the semaphore. 33 ``flags`` 34 How to create or open the semaphore. 35 ``mode`` 36 Unix style file mode to be used when creating the semaphore. 37 ``value`` 38 The initial value assigned to the semaphore. 39 40 41 Returns 42 ~~~~~~~ 43 44 A pointer to a PRSem structure or ``NULL/code> on error.`` 45 46 47 Description 48 ~~~~~~~~~~~ 49 50 If the named semaphore doesn't exist and the ``PR_SEM_CREATE`` flag is 51 specified, the named semaphore is created. The created semaphore needs 52 to be removed from the system with a :ref:`PR_DeleteSemaphore` call. 53 54 If ``PR_SEM_CREATE`` is specified, the third argument is the access 55 permission bits of the new semaphore (same interpretation as the mode 56 argument to :ref:`PR_Open`) and the fourth argument is the initial value of 57 the new semaphore. ``If PR_SEM_CREATE`` is not specified, the third and 58 fourth arguments are ignored.