Create a mutual exclusion semaphore.
CS_RETCODE srv_createmutex(mutex_namep, mutex_namelen, 
               mutex_idp)
CS_CHAR *mutex_namep; CS_INT mutex_namelen; SRV_OBJID *mutex_idp;
A pointer to the name of the mutex to create.
The length of the name in *mutex_namep. If the string is null terminated, an application can set mutex_namelen to CS_NULLTERM.
Open Server returns the ID of the new mutex in the *mutex_idp.
Returns  | 
To indicate  | 
|---|---|
CS_SUCCEED  | 
The routine completed successfully.  | 
CS_FAIL  | 
The routine failed.  | 
#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;
}
When creating a mutex, an application must assign it a name. Once a mutex has been created, the application can reference it either by name or by ID.
If you have the ID of a mutex, you can use srv_getobjname to look up the name.
Creating a mutex does not grant a lock to its creator. Use srv_lockmutex to lock it once a mutex has been created.
SRV_OBJID is defined as a CS_INT.
srv_deletemutex, srv_getobjname, srv_lockmutex, srv_unlockmutex