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/pspindestroy.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/pspindestroy.c')
-rw-r--r-- | cpukit/posix/src/pspindestroy.c | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/cpukit/posix/src/pspindestroy.c b/cpukit/posix/src/pspindestroy.c index ab45ad1e92..42a6e76806 100644 --- a/cpukit/posix/src/pspindestroy.c +++ b/cpukit/posix/src/pspindestroy.c @@ -18,58 +18,35 @@ #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 delete a spinlock specified by - * the spinlock id. The spinlock is freed back to the inactive - * spinlock chain. - * - * @param[in] spinlock is the 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_destroy( - pthread_spinlock_t *spinlock -) -{ - POSIX_Spinlock_Control *the_spinlock = NULL; - Objects_Locations location; +#include <errno.h> - if ( !spinlock ) - return EINVAL; +int pthread_spin_destroy( pthread_spinlock_t *spinlock ) +{ + POSIX_Spinlock_Control *the_spinlock; + ISR_lock_Context lock_context; _Objects_Allocator_lock(); - the_spinlock = _POSIX_Spinlock_Get( spinlock, &location ); - switch ( location ) { - case OBJECTS_LOCAL: - if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) { - _Objects_Put( &the_spinlock->Object ); - return EBUSY; - } - - _Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object ); - _Objects_Put( &the_spinlock->Object ); - _POSIX_Spinlock_Free( the_spinlock ); - _Objects_Allocator_unlock(); + the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context ); + if ( the_spinlock == NULL ) { + _Objects_Allocator_unlock(); + return EINVAL; + } - return 0; + _CORE_spinlock_Acquire_critical( &the_spinlock->Spinlock, &lock_context ); -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) { + _CORE_spinlock_Release( &the_spinlock->Spinlock, &lock_context ); + _Objects_Allocator_unlock(); + return EBUSY; } - _Objects_Allocator_unlock(); + _CORE_spinlock_Release( &the_spinlock->Spinlock, &lock_context ); - return EINVAL; + _Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object ); + _POSIX_Spinlock_Free( the_spinlock ); + _Objects_Allocator_unlock(); + return 0; } |