18 #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 23 #include <rtems/error.h> 30 #define RTEMS_FAST_MUTEX 35 #ifdef EPICS_RTEMS_SEMAPHORE_STATS 36 unsigned long semMstat[4];
37 #define SEMSTAT(i) semMstat[i]++; 47 rtems_interrupt_level level;
52 sc = rtems_semaphore_create (rtems_build_name (
'M', c3, c2, c1),
54 RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|RTEMS_INHERIT_PRIORITY|RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
57 if (sc != RTEMS_SUCCESSFUL) {
58 errlogPrintf (
"Can't create mutex semaphore: %s\n", rtems_status_text (sc));
61 rtems_interrupt_disable (level);
80 rtems_interrupt_enable (level);
81 #ifdef RTEMS_FAST_MUTEX 83 Semaphore_Control *the_semaphore;
84 Objects_Locations location;
86 the_semaphore = _Semaphore_Get( sid, &location );
87 _Thread_Enable_dispatch();
99 #ifdef RTEMS_FAST_MUTEX 100 Semaphore_Control *the_semaphore = (Semaphore_Control *)
id;
101 sid = the_semaphore->Object.id;
105 sc = rtems_semaphore_delete (sid);
106 if (sc == RTEMS_RESOURCE_IN_USE) {
107 rtems_semaphore_release (sid);
108 sc = rtems_semaphore_delete (sid);
110 if (sc != RTEMS_SUCCESSFUL)
111 errlogPrintf (
"Can't destroy semaphore %p (%lx): %s\n",
id, (
unsigned long)sid, rtems_status_text (sc));
116 #ifdef RTEMS_FAST_MUTEX 117 Semaphore_Control *the_semaphore = (Semaphore_Control *)
id;
118 _Thread_Disable_dispatch();
119 _CORE_mutex_Surrender (
120 &the_semaphore->Core_control.mutex,
121 the_semaphore->Object.id,
124 _Thread_Enable_dispatch();
133 #ifdef RTEMS_FAST_MUTEX 134 Semaphore_Control *the_semaphore = (Semaphore_Control *)
id;
137 _ISR_Disable( level );
139 &the_semaphore->Core_control.mutex,
140 the_semaphore->Object.id,
145 if (_Thread_Executing->Wait.return_code == 0)
158 #ifdef RTEMS_FAST_MUTEX 159 Semaphore_Control *the_semaphore = (Semaphore_Control *)
id;
162 _ISR_Disable( level );
164 &the_semaphore->Core_control.mutex,
165 the_semaphore->Object.id,
170 if (_Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_SUCCESSFUL)
172 else if (_Thread_Executing->Wait.return_code == CORE_MUTEX_STATUS_UNSATISFIED_NOWAIT)
190 #ifdef RTEMS_FAST_MUTEX 191 Semaphore_Control *the_semaphore = (Semaphore_Control *)
id;
#define epicsEventWait(ID)
void epicsMutexOsdUnlock(struct epicsMutexOSD *pmutex)
epicsMutexLockStatus epicsMutexOsdLock(struct epicsMutexOSD *pmutex)
#define epicsEventSignal(ID)
A synonym for epicsEventTrigger().
epicsMutexOSD * epicsMutexOsdCreate(void)
APIs for the epicsMutex mutual exclusion semaphore.
epicsMutexLockStatus epicsMutexOsdTryLock(struct epicsMutexOSD *pmutex)
int errlogPrintf(const char *pFormat,...)
APIs for the epicsEvent binary semaphore.
LIBCOM_API epicsEventStatus epicsEventTryWait(epicsEventId id)
Similar to wait() except that if the event is currenly empty the call will return immediately with st...
#define epicsEventWaitOK
Old name provided for backwards compatibility.
void epicsMutexOsdDestroy(struct epicsMutexOSD *pmutex)
#define epicsEventWaitStatus
Old name provided for backwards compatibility.
LIBCOM_API void epicsEventShow(epicsEventId id, unsigned int level)
Display information about the semaphore.
void epicsMutexOsdShow(struct epicsMutexOSD *pmutex, unsigned int level)