EPICS Base
7.0.7.0
|
APIs for the epicsMutex mutual exclusion semaphore. More...
#include "epicsAssert.h"
#include "libComAPI.h"
#include "compilerDependencies.h"
#include "epicsGuard.h"
#include "osdMutex.h"
Go to the source code of this file.
Classes | |
class | epicsMutex |
The C++ API for an epicsMutex. More... | |
class | epicsDeadlockDetectMutex |
A semaphore for locating deadlocks in C++ code. More... | |
Macros | |
#define | newEpicsMutex new epicsMutex(__FILE__,__LINE__) |
Create a C++ epicsMutex with current filename and line number. | |
#define | epicsMutexCreate() epicsMutexOsiCreate(__FILE__,__LINE__) |
Create an epicsMutex semaphore for use from C code. More... | |
#define | epicsMutexMustCreate() epicsMutexOsiMustCreate(__FILE__,__LINE__) |
Create an epicsMutex semaphore for use from C code. More... | |
#define | epicsMutexMustLock(ID) |
Claim a semaphore (see epicsMutexLock()). More... | |
Typedefs | |
typedef struct epicsMutexParm * | epicsMutexId |
An identifier for an epicsMutex for use with the C API. | |
Enumerations | |
enum | epicsMutexLockStatus { epicsMutexLockOK = 0, epicsMutexLockTimeout, epicsMutexLockError } |
Functions | |
LIBCOM_API epicsMutexId epicsStdCall | epicsMutexOsiCreate (const char *pFileName, int lineno) |
Internal API, used by epicsMutexCreate(). | |
LIBCOM_API epicsMutexId epicsStdCall | epicsMutexOsiMustCreate (const char *pFileName, int lineno) |
Internal API, used by epicsMutexMustCreate(). | |
LIBCOM_API void epicsStdCall | epicsMutexDestroy (epicsMutexId id) |
Destroy an epicsMutex semaphore. More... | |
LIBCOM_API void epicsStdCall | epicsMutexUnlock (epicsMutexId id) |
Release the semaphore. More... | |
LIBCOM_API epicsMutexLockStatus epicsStdCall | epicsMutexLock (epicsMutexId id) |
Claim the semaphore, waiting until it's free if currently owned owned by a different thread. More... | |
LIBCOM_API epicsMutexLockStatus epicsStdCall | epicsMutexTryLock (epicsMutexId id) |
Similar to epicsMutexLock() except that the call returns immediately, with the return status indicating if the semaphore is currently owned by this thread or another thread. More... | |
LIBCOM_API void epicsStdCall | epicsMutexShow (epicsMutexId id, unsigned int level) |
Display information about the semaphore. More... | |
LIBCOM_API void epicsStdCall | epicsMutexShowAll (int onlyLocked, unsigned int level) |
Display information about all epicsMutex semaphores. More... | |
Mutual exclusion semaphores are for situations requiring exclusive access to resources. An epicsMutex may be claimed recursively, i.e. taken more than once by a thread, which must release it as many times as it was taken. Recursive usage is common for a set of routines that call each other while working on an exclusive resource.
The typical C++ use of a mutual exclusion semaphore is:
Definition in file epicsMutex.h.
#define epicsMutexCreate | ( | ) | epicsMutexOsiCreate(__FILE__,__LINE__) |
This macro stores the source location of the creation call in the mutex.
Definition at line 169 of file epicsMutex.h.
#define epicsMutexMustCreate | ( | ) | epicsMutexOsiMustCreate(__FILE__,__LINE__) |
This macro stores the source location of the creation call in the mutex. The routine does not return if the object could not be created.
Definition at line 180 of file epicsMutex.h.
#define epicsMutexMustLock | ( | ID | ) |
This routine does not return if the identifier is invalid.
ID | The mutex identifier. |
Definition at line 215 of file epicsMutex.h.
enum epicsMutexLockStatus |
Return status from some C API routines.
Definition at line 52 of file epicsMutex.h.
LIBCOM_API void epicsStdCall epicsMutexDestroy | ( | epicsMutexId | id | ) |
id | The mutex identifier. |
LIBCOM_API void epicsStdCall epicsMutexUnlock | ( | epicsMutexId | id | ) |
id | The mutex identifier. |
LIBCOM_API epicsMutexLockStatus epicsStdCall epicsMutexLock | ( | epicsMutexId | id | ) |
This call blocks until the calling thread can get exclusive access to the semaphore.
id | The mutex identifier. |
LIBCOM_API epicsMutexLockStatus epicsStdCall epicsMutexTryLock | ( | epicsMutexId | id | ) |
epicsMutexLockOK
if the resource is now owned by the caller. epicsMutexLockTimeout
if some other thread owns the resource. LIBCOM_API void epicsStdCall epicsMutexShow | ( | epicsMutexId | id, |
unsigned int | level | ||
) |
id | The mutex identifier. |
level | Desired information level to report |
LIBCOM_API void epicsStdCall epicsMutexShowAll | ( | int | onlyLocked, |
unsigned int | level | ||
) |
onlyLocked | Non-zero to show only locked semaphores. |
level | Desired information level to report |