diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-27 15:41:41 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-30 16:16:23 +0200 |
commit | 33e250c9fa370f620ddbc5850342d5a90b123524 (patch) | |
tree | a2f4082a58231054f084e9a77aa0af4e3111662d /cpukit/score/src | |
parent | score: Add CORE mutex variants (diff) | |
download | rtems-33e250c9fa370f620ddbc5850342d5a90b123524.tar.bz2 |
score: Rework CORE priority ceiling mutex
Rework seize and surrender methods to use CORE_ceiling_mutex_Control.
This eliminates CORE_mutex_Disciplines.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/src/apimutex.c | 4 | ||||
-rw-r--r-- | cpukit/score/src/coremutex.c | 32 | ||||
-rw-r--r-- | cpukit/score/src/coremutexseize.c | 33 | ||||
-rw-r--r-- | cpukit/score/src/coremutexsurrender.c | 16 |
4 files changed, 19 insertions, 66 deletions
diff --git a/cpukit/score/src/apimutex.c b/cpukit/score/src/apimutex.c index 8af374aaef..e3c6e5a705 100644 --- a/cpukit/score/src/apimutex.c +++ b/cpukit/score/src/apimutex.c @@ -48,9 +48,7 @@ void _API_Mutex_Allocate( API_Mutex_Control *mutex; CORE_mutex_Attributes attr = { - CORE_MUTEX_NESTING_ACQUIRES, - CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT, - 0 + CORE_MUTEX_NESTING_ACQUIRES }; mutex = (API_Mutex_Control *) diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index 6f73c1bd16..9c6b7a8b93 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -39,41 +39,9 @@ Status_Control _CORE_mutex_Initialize( the_mutex->Attributes = *the_mutex_attributes; if ( initially_locked ) { - bool is_priority_ceiling; - Priority_Control ceiling; - Per_CPU_Control *cpu_self; - the_mutex->nest_count = 1; the_mutex->holder = executing; - - /* 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 ) { - /* - * 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++; - - if ( is_priority_ceiling ) { - _Thread_Raise_priority( executing, ceiling ); - } - - _Thread_Dispatch_enable( cpu_self ); } else { the_mutex->nest_count = 0; the_mutex->holder = NULL; diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index 596378fda6..ed5eb0aeec 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -29,6 +29,8 @@ Status_Control _CORE_mutex_Seize_interrupt_blocking( Thread_queue_Context *queue_context ) { + Thread_Control *holder; + #if !defined(RTEMS_SMP) /* * We must disable thread dispatching here since we enable the interrupts for @@ -37,32 +39,27 @@ Status_Control _CORE_mutex_Seize_interrupt_blocking( _Thread_Dispatch_disable(); #endif - if ( _CORE_mutex_Is_inherit_priority( &the_mutex->Attributes ) ) { - Thread_Control *holder = the_mutex->holder; + holder = the_mutex->holder; #if !defined(RTEMS_SMP) - /* - * To enable interrupts here works only since exactly one executing thread - * exists and only threads are allowed to seize and surrender mutexes with - * the priority inheritance protocol. On SMP configurations more than one - * executing thread may exist, so here we must not release the lock, since - * otherwise the current holder may be no longer the holder of the mutex - * once we released the lock. - */ - _CORE_mutex_Release( the_mutex, queue_context ); + /* + * To enable interrupts here works only since exactly one executing thread + * exists and only threads are allowed to seize and surrender mutexes with + * the priority inheritance protocol. On SMP configurations more than one + * executing thread may exist, so here we must not release the lock, since + * otherwise the current holder may be no longer the holder of the mutex + * once we released the lock. + */ + _CORE_mutex_Release( the_mutex, queue_context ); #endif - _Thread_Inherit_priority( holder, executing ); - -#if !defined(RTEMS_SMP) - _ISR_lock_ISR_disable( &queue_context->Lock_context ); - _CORE_mutex_Acquire_critical( the_mutex, queue_context ); -#endif - } + _Thread_Inherit_priority( holder, executing ); #if defined(RTEMS_SMP) _Thread_queue_Context_set_expected_level( queue_context, 1 ); #else + _ISR_lock_ISR_disable( &queue_context->Lock_context ); + _CORE_mutex_Acquire_critical( the_mutex, queue_context ); _Thread_queue_Context_set_expected_level( queue_context, 2 ); #endif diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index 2d976e0c22..5075e204c9 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -118,19 +118,8 @@ Status_Control _CORE_mutex_Surrender( if ( _Objects_Is_local_id( the_thread->Object.id ) ) #endif { - switch ( the_mutex->Attributes.discipline ) { - case CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT: - the_thread->resource_count++; - _Thread_queue_Boost_priority( &the_mutex->Wait_queue.Queue, the_thread ); - break; - case CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING: - the_thread->resource_count++; - _Thread_Raise_priority( - the_thread, - the_mutex->Attributes.priority_ceiling - ); - break; - } + the_thread->resource_count++; + _Thread_queue_Boost_priority( &the_mutex->Wait_queue.Queue, the_thread ); } _Thread_queue_Unblock_critical( @@ -164,5 +153,6 @@ Status_Control _CORE_mutex_Surrender( } } + _CORE_mutex_Restore_priority( holder ); return STATUS_SUCCESSFUL; } |