From 7cf6e3bcdd55525cb8ce9ee585a092cd9935bbc0 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 8 Jan 2003 01:02:31 +0000 Subject: [PATCH] doc --- src/libCom/osi/os/posix/osdMutex.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libCom/osi/os/posix/osdMutex.c b/src/libCom/osi/os/posix/osdMutex.c index 575d9eb8e..93fcf4c90 100644 --- a/src/libCom/osi/os/posix/osdMutex.c +++ b/src/libCom/osi/os/posix/osdMutex.c @@ -43,7 +43,7 @@ if(status) { \ /* Three completely different implementations are provided below * If support is available for _POSIX_SPIN_LOCK is available - * then pthread_spin is used + * and enabled then pthread_spin is used * If support is available for PTHREAD_MUTEX_RECURSIVE then * only pthread_mutex is used. * If support is not available for PTHREAD_MUTEX_RECURSIVE then @@ -52,6 +52,12 @@ if(status) { \ #if defined ( _POSIX_SPIN_LOCKS ) && ( _POSIX_SPIN_LOCKS ) >= 200112L && EPICS_TEST_SPINLOCKS +/* + * !!!! the following is not safe on multi processor systems !!!! + * The problem is that "owner" and "owned" flags must not be accessed + * on a MP system w/o taking a lock and enforcing a memory barrier. + */ + typedef struct epicsMutexOSD { pthread_spinlock_t lock; pthread_t owner; @@ -121,7 +127,7 @@ epicsMutexLockStatus epicsMutexOsdTryLock(struct epicsMutexOSD * pmutex) if ( pthreadStatus == EBUSY ) return ( epicsMutexLockTimeout ); checkStatusQuit ( pthreadStatus, "pthread_spin_trylock", "epicsMutexOsdTryLock" ); - } + } pmutex->owned = 1; pmutex->owner = self; }