diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-27 08:02:03 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 16:16:23 +0200 |
commit | 5a598ac99b0de720a04afc5e2ac6764117589b90 (patch) | |
tree | 811d57df33c0f4fcc1cce61095cb5c0a33eadd7c /cpukit/score/src/coremutex.c | |
parent | posix: Delete POSIX_Mutex_Protocol::process_shared (diff) | |
download | rtems-5a598ac99b0de720a04afc5e2ac6764117589b90.tar.bz2 |
score: Add CORE mutex variants
Add CORE_recursive_mutex_Control and CORE_ceiling_mutex_Control to avoid
the run-time evaluation of attributes to figure out how a particular
mutex methods should behave. Start with the no protocol variants. This
eliminates the CORE_MUTEX_DISCIPLINES_FIFO and
CORE_MUTEX_DISCIPLINES_PRIORITY disciplines.
Diffstat (limited to 'cpukit/score/src/coremutex.c')
-rw-r--r-- | cpukit/score/src/coremutex.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index ec073ff999..6f73c1bd16 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -39,42 +39,41 @@ Status_Control _CORE_mutex_Initialize( the_mutex->Attributes = *the_mutex_attributes; if ( initially_locked ) { - bool is_priority_ceiling = - _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ); + bool is_priority_ceiling; + Priority_Control ceiling; + Per_CPU_Control *cpu_self; the_mutex->nest_count = 1; the_mutex->holder = executing; - if ( is_priority_ceiling || - _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { - Priority_Control ceiling = the_mutex->Attributes.priority_ceiling; - Per_CPU_Control *cpu_self; - - /* The mutex initialization is only protected by the allocator lock */ - cpu_self = _Thread_Dispatch_disable(); + /* The mutex initialization is only protected by the allocator lock */ + cpu_self = _Thread_Dispatch_disable(); + is_priority_ceiling = + _CORE_mutex_Is_priority_ceiling( &the_mutex->Attributes ); + ceiling = the_mutex->Attributes.priority_ceiling; + + /* + * The test to check for a ceiling violation is a bit arbitrary. In case + * this thread is the owner of a priority inheritance mutex, then it may + * get a higher priority later or anytime on SMP configurations. + */ + if ( is_priority_ceiling && executing->current_priority < ceiling ) { /* - * The test to check for a ceiling violation is a bit arbitrary. In case - * this thread is the owner of a priority inheritance mutex, then it may - * get a higher priority later or anytime on SMP configurations. + * There is no need to undo the previous work since this error aborts + * the object creation. */ - if ( is_priority_ceiling && executing->current_priority < ceiling ) { - /* - * There is no need to undo the previous work since this error aborts - * the object creation. - */ - _Thread_Dispatch_enable( cpu_self ); - return STATUS_MUTEX_CEILING_VIOLATED; - } - - executing->resource_count++; + _Thread_Dispatch_enable( cpu_self ); + return STATUS_MUTEX_CEILING_VIOLATED; + } - if ( is_priority_ceiling ) { - _Thread_Raise_priority( executing, ceiling ); - } + executing->resource_count++; - _Thread_Dispatch_enable( cpu_self ); + if ( is_priority_ceiling ) { + _Thread_Raise_priority( executing, ceiling ); } + + _Thread_Dispatch_enable( cpu_self ); } else { the_mutex->nest_count = 0; the_mutex->holder = NULL; @@ -82,11 +81,5 @@ Status_Control _CORE_mutex_Initialize( _Thread_queue_Initialize( &the_mutex->Wait_queue ); - if ( _CORE_mutex_Is_fifo( the_mutex_attributes ) ) { - the_mutex->operations = &_Thread_queue_Operations_FIFO; - } else { - the_mutex->operations = &_Thread_queue_Operations_priority; - } - return STATUS_SUCCESSFUL; } |