srv_createmutex

Description

Create a mutual exclusion semaphore.

Syntax

CS_RETCODE srv_createmutex(mutex_namep, mutex_namelen, 
               mutex_idp)
CS_CHAR          *mutex_namep;
CS_INT               mutex_namelen;
SRV_OBJID       *mutex_idp;

Parameters

mutex_namep

A pointer to the name of the mutex to create.

mutex_namelen

The length of the name in *mutex_namep. If the string is null terminated, an application can set mutex_namelen to CS_NULLTERM.

mutex_idp

Open Server returns the ID of the new mutex in the *mutex_idp.

Returns

Table 3-25: Return values (srv_createmutex)

Returns

To indicate

CS_SUCCEED

The routine completed successfully.

CS_FAIL

The routine failed.

Examples

Example 1

#include     <ospublic.h>
/*
 ** Local Prototype.
 */
CS_RETCODE               ex_srv_createmutex PROTOTYPE((
CS_CHAR           *name,
CS_INT            namelen,
SRV_OBJID         *idp
));

/* 
** EX_SRV_CREATEMUTEX
**
**     Example routine to create an Open Server mutex.
**
** Arguments:
**
**     name      The name of the mutex to create.
**     namelen   The length of name.
**     idp       The address of a SRV_OBJID, which will be set
 **               to the unique identifier for the created mutex.
**
** Returns:
**          CS_SUCCEED      The mutex was created successfuly.
**          CS_FAIL         An error was detected.
*/
CS_RETCODE           ex_srv_createmutex(name, namelen, idp)
CS_CHAR              *name;
CS_INT               namelen;
SRV_OBJID            *idp;
{
     /*
     ** Call the Open Server routine that will create
      ** the mutex.
     */
     if( srv_createmutex(name, namelen, idp) == CS_FAIL )
     {
          /*
          ** An error was al&ready raised.
          */
          return CS_FAIL;
     }
     
     /*
     ** All done.
     */
     return CS_SUCCEED;
}

Usage

See also

srv_deletemutex, srv_getobjname, srv_lockmutex, srv_unlockmutex