Unlock a mutex.
CS_RETCODE srv_unlockmutex(mutexid)
SRV_OBJID mutexid;
The unique mutex identifier that was returned by srv_createmutex. mutexid can be obtained from the mutex name with srv_getobjid.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_unlockmutex PROTOTYPE((
CS_CHAR *mutex_name
));
/*
** EX_SRV_UNLOCKMUTEX
**
** Example routine to illustrate the use of srv_unlockmutex.
**
** Arguments:
** mutex_name The name of the mutex to be unlocked.
**
** Returns:
**
** CS_SUCCEED Mutex successfully unlocked.
** CS_FAIL An error was detected.
*/
CS_RETCODE ex_srv_unlockmutex(mutex_name)
CS_CHAR *mutex_name;
{
SRV_OBJID id;
CS_INT info;
/* Get the object id for the mutex. */
if (srv_getobjid(SRV_C_MUTEX, mutex_name, CS_NULLTERM,
&id, &info) == CS_FAIL)
return (CS_FAIL);
/* Call srv_unlockmutex to unlock it. */
if (srv_unlockmutex(id) == CS_FAIL)
return (CS_FAIL);
return (CS_SUCCEED);
}
Unlocking a mutex (mutual exclusion semaphore) releases the lock held on the semaphore, allowing other threads to access the mutex.
srv_unlockmutex cannot be used in a SRV_START handler.