diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 14:03:01 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-18 15:36:58 +0100 |
commit | 5a5fb3b9d6d99d6751d129458217f1a3b5b85ff8 (patch) | |
tree | 9f2296b7e4abaa0da454caea84e2fcbc0eb49fd2 /cpukit/posix/src/pspinlock.c | |
parent | score: Add _Objects_Get_by_name() (diff) | |
download | rtems-5a5fb3b9d6d99d6751d129458217f1a3b5b85ff8.tar.bz2 |
score: Avoid Giant lock for CORE spinlock
Use an ISR lock to protect the spinlock state. Remove empty attributes.
Update #2555.
Diffstat (limited to 'cpukit/posix/src/pspinlock.c')
-rw-r--r-- | cpukit/posix/src/pspinlock.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/cpukit/posix/src/pspinlock.c b/cpukit/posix/src/pspinlock.c index d13ffe6b5c..502177c50e 100644 --- a/cpukit/posix/src/pspinlock.c +++ b/cpukit/posix/src/pspinlock.c @@ -18,46 +18,26 @@ #include "config.h" #endif -#include <pthread.h> -#include <errno.h> - -#include <rtems/system.h> #include <rtems/posix/spinlockimpl.h> -/** - * This directive allows a thread to wait at a spinlock. - * - * @param[in] spinlock is spinlock id - * - * @return This method returns 0 if there was not an - * error. Otherwise, a status code is returned indicating the - * source of the error. - */ -int pthread_spin_lock( - pthread_spinlock_t *spinlock -) +#include <errno.h> + +int pthread_spin_lock( pthread_spinlock_t *spinlock ) { - POSIX_Spinlock_Control *the_spinlock = NULL; - Objects_Locations location; - CORE_spinlock_Status status; + POSIX_Spinlock_Control *the_spinlock; + ISR_lock_Context lock_context; + CORE_spinlock_Status status; - if ( !spinlock ) + the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context ); + if ( the_spinlock == NULL ) { return EINVAL; - - the_spinlock = _POSIX_Spinlock_Get( spinlock, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - status = _CORE_spinlock_Wait( &the_spinlock->Spinlock, true, 0 ); - _Objects_Put( &the_spinlock->Object ); - return _POSIX_Spinlock_Translate_core_spinlock_return_code( status ); - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; } - return EINVAL; + status = _CORE_spinlock_Seize( + &the_spinlock->Spinlock, + true, + 0, + &lock_context + ); + return _POSIX_Spinlock_Translate_core_spinlock_return_code( status ); } |