diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-12-07 11:48:36 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-12-11 09:05:07 +0100 |
commit | 01f8c12ee57230fca1581e1b5be91f3decba0488 (patch) | |
tree | 279ef8193d107ea59490e3fdeb18d20639c54f36 /cpukit/rtems/src/semobtain.c | |
parent | score: Optimize _TLS_Get_size() (diff) | |
download | rtems-01f8c12ee57230fca1581e1b5be91f3decba0488.tar.bz2 |
rtems: Optimize semaphore control block
Move variant, discipline, and global information to flags stored in a
node pointer of active semaphores.
Update #3833.
Diffstat (limited to 'cpukit/rtems/src/semobtain.c')
-rw-r--r-- | cpukit/rtems/src/semobtain.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c index 2f73166df0..5916cf5e69 100644 --- a/cpukit/rtems/src/semobtain.c +++ b/cpukit/rtems/src/semobtain.c @@ -58,6 +58,8 @@ rtems_status_code rtems_semaphore_obtain( Thread_queue_Context queue_context; Thread_Control *executing; bool wait; + uintptr_t flags; + Semaphore_Variant variant; Status_Control status; the_semaphore = _Semaphore_Get( id, &queue_context ); @@ -79,7 +81,10 @@ rtems_status_code rtems_semaphore_obtain( _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); } - switch ( the_semaphore->variant ) { + flags = _Semaphore_Get_flags( the_semaphore ); + variant = _Semaphore_Get_variant( flags ); + + switch ( variant ) { case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY: status = _CORE_recursive_mutex_Seize( &the_semaphore->Core_control.Mutex.Recursive, @@ -102,7 +107,7 @@ rtems_status_code rtems_semaphore_obtain( case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL: status = _CORE_recursive_mutex_Seize( &the_semaphore->Core_control.Mutex.Recursive, - _Semaphore_Get_operations( the_semaphore ), + _Semaphore_Get_operations( flags ), executing, wait, _CORE_recursive_mutex_Seize_nested, @@ -121,12 +126,12 @@ rtems_status_code rtems_semaphore_obtain( #endif default: _Assert( - the_semaphore->variant == SEMAPHORE_VARIANT_SIMPLE_BINARY - || the_semaphore->variant == SEMAPHORE_VARIANT_COUNTING + variant == SEMAPHORE_VARIANT_SIMPLE_BINARY + || variant == SEMAPHORE_VARIANT_COUNTING ); status = _CORE_semaphore_Seize( &the_semaphore->Core_control.Semaphore, - _Semaphore_Get_operations( the_semaphore ), + _Semaphore_Get_operations( flags ), executing, wait, &queue_context |