#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include "epicsMutex.h"
#include "cantProceed.h"
#include "epicsTime.h"
#include "errlog.h"
#include "epicsAssert.h"
Go to the source code of this file.
#define checkStatus |
( |
|
status, |
|
|
|
message |
|
) |
| |
Value: (message), strerror((
status))); \
}
int errlogPrintf(const char *pFormat,...)
Definition at line 29 of file osdMutex.c.
#define checkStatusQuit |
( |
|
status, |
|
|
|
message, |
|
|
|
method |
|
) |
| |
Value: }
int errlogPrintf(const char *pFormat,...)
LIBCOM_API void cantProceed(const char *msg,...)
Definition at line 34 of file osdMutex.c.
The following are interfaces to the OS dependent implementation and should NOT be called directly by user code.
Definition at line 175 of file osdMutex.c.
179 pmutex = calloc(1,
sizeof(*pmutex));
183 status = pthread_mutexattr_init(&pmutex->
mutexAttr);
187 #if defined(_POSIX_THREAD_PRIO_INHERIT) && _POSIX_THREAD_PRIO_INHERIT > 0 188 status = pthread_mutexattr_setprotocol(
189 &pmutex->
mutexAttr,PTHREAD_PRIO_INHERIT);
193 status = pthread_mutex_init(&pmutex->
lock, &pmutex->
mutexAttr);
197 #if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED > 0 198 status = pthread_condattr_init(&pmutex->condAttr);
200 status = pthread_condattr_setpshared(&pmutex->condAttr,
201 PTHREAD_PROCESS_PRIVATE);
202 checkStatus(status,
"pthread_condattr_setpshared");
203 status = pthread_cond_init(&pmutex->
waitToBeOwner, &pmutex->condAttr);
213 pthread_mutex_destroy(&pmutex->
lock);
215 pthread_mutexattr_destroy(&pmutex->
mutexAttr);
#define checkStatus(status, message)
pthread_mutexattr_t mutexAttr
pthread_cond_t waitToBeOwner
Definition at line 221 of file osdMutex.c.
227 #if defined(_POSIX_THREAD_PROCESS_SHARED) && _POSIX_THREAD_PROCESS_SHARED > 0 228 status = pthread_condattr_destroy(&pmutex->condAttr);
230 status = pthread_mutex_destroy(&pmutex->
lock);
232 status = pthread_mutexattr_destroy(&pmutex->
mutexAttr);
#define checkStatus(status, message)
pthread_mutexattr_t mutexAttr
pthread_cond_t waitToBeOwner
Definition at line 276 of file osdMutex.c.
278 pthread_t tid = pthread_self();
282 status = mutexLock(&pmutex->
lock);
284 checkStatus(status,
"pthread_mutex_lock epicsMutexOsdLock");
288 while (pmutex->
owned && !pthread_equal(pmutex->
ownerTid, tid))
294 status = pthread_mutex_unlock(&pmutex->
lock);
295 checkStatus(status,
"pthread_mutex_unlock epicsMutexOsdLock");
#define checkStatus(status, message)
pthread_cond_t waitToBeOwner
void epicsMutexOsdShow |
( |
struct epicsMutexOSD * |
pmutex, |
|
|
unsigned int |
level |
|
) |
| |
Definition at line 301 of file osdMutex.c.
303 pthread_t tid = pthread_self();
307 status = mutexLock(&pmutex->
lock);
309 checkStatus(status,
"pthread_mutex_lock epicsMutexOsdTryLock");
313 if (!pmutex->
owned || pthread_equal(pmutex->
ownerTid, tid)) {
322 status = pthread_mutex_unlock(&pmutex->
lock);
323 checkStatus(status,
"pthread_mutex_unlock epicsMutexOsdTryLock");
#define checkStatus(status, message)
Definition at line 237 of file osdMutex.c.
241 status = mutexLock(&pmutex->
lock);
242 checkStatus(status,
"pthread_mutex_lock epicsMutexOsdUnlock");
246 if ((pmutex->
count <= 0) || (pmutex->
ownerTid != pthread_self())) {
247 pthread_mutex_unlock(&pmutex->
lock);
248 checkStatus(status,
"pthread_mutex_unlock epicsMutexOsdUnlock");
249 errlogPrintf(
"epicsMutexOsdUnlock but caller is not owner\n");
250 cantProceed(
"epicsMutexOsdUnlock but caller is not owner");
255 if (pmutex->
count == 0) {
259 checkStatusQuit(status,
"pthread_cond_signal epicsMutexOsdUnlock",
"epicsMutexOsdUnlock");
262 status = pthread_mutex_unlock(&pmutex->
lock);
263 checkStatus(status,
"pthread_mutex_unlock epicsMutexOsdUnlock");
#define checkStatus(status, message)
#define checkStatusQuit(status, message, method)
int errlogPrintf(const char *pFormat,...)
LIBCOM_API void cantProceed(const char *msg,...)
pthread_cond_t waitToBeOwner