diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-19 17:02:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-04-22 09:25:08 +0200 |
commit | 4025a60fcb892169266102a58beef4caad17340c (patch) | |
tree | 004df492a31db98faa24335a663eed429ebb5d05 /cpukit/rtems/src/semflush.c | |
parent | posix: Avoid Giant lock in sem_getvalue() (diff) | |
download | rtems-4025a60fcb892169266102a58beef4caad17340c.tar.bz2 |
score: Avoid Giant lock for CORE mtx/sem
Avoid Giant lock for CORE mutex and semaphore flush and delete
operations.
Update #2555.
Diffstat (limited to 'cpukit/rtems/src/semflush.c')
-rw-r--r-- | cpukit/rtems/src/semflush.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c index 01c5c0ddcd..13dcf22785 100644 --- a/cpukit/rtems/src/semflush.c +++ b/cpukit/rtems/src/semflush.c @@ -37,39 +37,52 @@ rtems_status_code rtems_semaphore_flush( { Semaphore_Control *the_semaphore; Objects_Locations location; + ISR_lock_Context lock_context; rtems_attribute attribute_set; - the_semaphore = _Semaphore_Get( id, &location ); + the_semaphore = _Semaphore_Get_interrupt_disable( + id, + &location, + &lock_context + ); switch ( location ) { case OBJECTS_LOCAL: attribute_set = the_semaphore->attribute_set; #if defined(RTEMS_SMP) if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) { - _Objects_Put( &the_semaphore->Object ); + _ISR_lock_ISR_enable( &lock_context ); return RTEMS_NOT_DEFINED; } else #endif if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) { + _CORE_mutex_Acquire_critical( + &the_semaphore->Core_control.mutex, + &lock_context + ); _CORE_mutex_Flush( &the_semaphore->Core_control.mutex, _CORE_mutex_Unsatisfied_nowait, _Semaphore_MP_Send_object_was_deleted, - id + id, + &lock_context ); } else { + _CORE_semaphore_Acquire_critical( + &the_semaphore->Core_control.semaphore, + &lock_context + ); _CORE_semaphore_Flush( &the_semaphore->Core_control.semaphore, _Semaphore_MP_Send_object_was_deleted, - id + id, + &lock_context ); } - _Objects_Put( &the_semaphore->Object ); return RTEMS_SUCCESSFUL; #if defined(RTEMS_MULTIPROCESSING) case OBJECTS_REMOTE: - _Thread_Dispatch(); return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; #endif |