From 0e1d11f3f0f02768ced350fcb53056c55f0c545b Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 27 May 2016 13:26:53 +0200 Subject: score: Add _Thread_queue_Context_set_MP_callout() Add _Thread_queue_Context_set_MP_callout() to simplify _Thread_queue_Context_initialize(). This makes it possible to more easily add additional fields to Thread_queue_Context. --- cpukit/score/include/rtems/score/mrspimpl.h | 2 +- cpukit/score/include/rtems/score/threadq.h | 15 ++++++++ cpukit/score/include/rtems/score/threadqimpl.h | 47 ++++++++++++-------------- cpukit/score/src/apimutexlock.c | 2 +- cpukit/score/src/apimutexunlock.c | 2 +- cpukit/score/src/condition.c | 2 +- cpukit/score/src/mpci.c | 2 +- cpukit/score/src/mutex.c | 4 +-- cpukit/score/src/semaphore.c | 2 +- cpukit/score/src/threadqenqueue.c | 12 ++++--- cpukit/score/src/threadrestart.c | 2 +- 11 files changed, 53 insertions(+), 39 deletions(-) (limited to 'cpukit/score') diff --git a/cpukit/score/include/rtems/score/mrspimpl.h b/cpukit/score/include/rtems/score/mrspimpl.h index ffdc802f6f..5a1fcda54d 100644 --- a/cpukit/score/include/rtems/score/mrspimpl.h +++ b/cpukit/score/include/rtems/score/mrspimpl.h @@ -189,7 +189,7 @@ RTEMS_INLINE_ROUTINE void _MRSP_Timeout( Watchdog_Control *watchdog ) Thread_Control *thread = rival->thread; Thread_queue_Context queue_context; - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context ); _MRSP_Acquire_critical( mrsp, &queue_context ); diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h index 467462d2b8..5f2ffe49a9 100644 --- a/cpukit/score/include/rtems/score/threadq.h +++ b/cpukit/score/include/rtems/score/threadq.h @@ -63,7 +63,22 @@ typedef void ( *Thread_queue_MP_callout )( * @see _Thread_queue_Context_initialize(). */ typedef struct { + /** + * @brief The lock context for the thread queue acquire and release + * operations. + */ ISR_lock_Context Lock_context; + + /** + * @brief Callout to unblock the thread in case it is actually a thread + * proxy. + * + * This field is only used on multiprocessing configurations. Used by + * thread queue extract and unblock methods for objects with multiprocessing + * (MP) support. + * + * @see _Thread_queue_Context_set_MP_callout(). + */ #if defined(RTEMS_MULTIPROCESSING) Thread_queue_MP_callout mp_callout; #endif diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index a8f404f299..4f5b48b6eb 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -53,47 +53,44 @@ typedef struct { Thread_queue_Queue Queue; } Thread_queue_Syslock_queue; -RTEMS_INLINE_ROUTINE void _Thread_queue_Do_context_initialize( - Thread_queue_Context *queue_context -#if defined(RTEMS_MULTIPROCESSING) - , - Thread_queue_MP_callout mp_callout -#endif +/** + * @brief Initializes a thread queue context. + * + * @param queue_context The thread queue context to initialize. + */ +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_initialize( + Thread_queue_Context *queue_context ) { -#if defined(RTEMS_MULTIPROCESSING) - queue_context->mp_callout = mp_callout; +#if defined(RTEMS_MULTIPROCESSING) && defined(RTEMS_DEBUG) + queue_context->mp_callout = NULL; #else (void) queue_context; #endif } /** - * @brief Initializes a thread queue context. + * @brief Sets the MP callout in the thread queue context. * - * @param queue_context The thread queue context to initialize. + * @param queue_context The thread queue context. * @param mp_callout Callout to unblock the thread in case it is actually a * thread proxy. This parameter is only used on multiprocessing * configurations. Used by thread queue extract and unblock methods for * objects with multiprocessing (MP) support. */ #if defined(RTEMS_MULTIPROCESSING) - #define _Thread_queue_Context_initialize( \ - queue_context, \ - mp_callout \ - ) \ - _Thread_queue_Do_context_initialize( \ - queue_context, \ - mp_callout \ - ) +RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_MP_callout( + Thread_queue_Context *queue_context, + Thread_queue_MP_callout mp_callout +) +{ + queue_context->mp_callout = mp_callout; +} #else - #define _Thread_queue_Context_initialize( \ - queue_context, \ - mp_callout \ - ) \ - _Thread_queue_Do_context_initialize( \ - queue_context \ - ) +#define _Thread_queue_Context_set_MP_callout( queue_context, mp_callout ) \ + do { \ + (void) queue_context; \ + } while ( 0 ) #endif RTEMS_INLINE_ROUTINE void _Thread_queue_Heads_initialize( diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c index 11d12c5a7e..7a7f911f84 100644 --- a/cpukit/score/src/apimutexlock.c +++ b/cpukit/score/src/apimutexlock.c @@ -31,7 +31,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex ) previous_thread_life_state = _Thread_Set_life_protection( THREAD_LIFE_PROTECTED ); - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context ); _CORE_mutex_Seize( diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c index f0f114e0bf..486301fa82 100644 --- a/cpukit/score/src/apimutexunlock.c +++ b/cpukit/score/src/apimutexunlock.c @@ -31,7 +31,7 @@ void _API_Mutex_Unlock( API_Mutex_Control *the_mutex ) previous_thread_life_state = the_mutex->previous_thread_life_state; restore_thread_life_protection = the_mutex->Mutex.nest_count == 1; - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); _ISR_lock_ISR_disable( &queue_context.Lock_context ); _CORE_mutex_Surrender( &the_mutex->Mutex, &queue_context ); diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c index 39924e8c92..fae150a7cd 100644 --- a/cpukit/score/src/condition.c +++ b/cpukit/score/src/condition.c @@ -247,7 +247,7 @@ static void _Condition_Wake( struct _Condition_Control *_condition, int count ) Condition_Context context; condition = _Condition_Get( _condition ); - _Thread_queue_Context_initialize( &context.Base, NULL ); + _Thread_queue_Context_initialize( &context.Base ); _ISR_lock_ISR_disable( &context.Base.Lock_context ); _Condition_Queue_acquire_critical( condition, &context.Base.Lock_context ); diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 78d8e657fa..1e26b1f3ce 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -325,7 +325,7 @@ void _MPCI_Receive_server( Thread_queue_Context queue_context; executing = _Thread_Get_executing(); - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); for ( ; ; ) { diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c index eea15a05dc..6a85850a89 100644 --- a/cpukit/score/src/mutex.c +++ b/cpukit/score/src/mutex.c @@ -293,7 +293,7 @@ void _Mutex_Release( struct _Mutex_Control *_mutex ) Thread_Control *executing; mutex = _Mutex_Get( _mutex ); - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); executing = _Mutex_Queue_acquire( mutex, &queue_context.Lock_context ); _Assert( mutex->Queue.Queue.owner == executing ); @@ -422,7 +422,7 @@ void _Mutex_recursive_Release( struct _Mutex_recursive_Control *_mutex ) unsigned int nest_level; mutex = _Mutex_recursive_Get( _mutex ); - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); executing = _Mutex_Queue_acquire( &mutex->Mutex, &queue_context.Lock_context diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c index ea0835d7b5..72abd9e12a 100644 --- a/cpukit/score/src/semaphore.c +++ b/cpukit/score/src/semaphore.c @@ -114,7 +114,7 @@ void _Semaphore_Post( struct _Semaphore_Control *_sem ) Thread_queue_Heads *heads; sem = _Semaphore_Get( _sem ); - _Thread_queue_Context_initialize( &queue_context, NULL ); + _Thread_queue_Context_initialize( &queue_context ); _Semaphore_Queue_acquire( sem, &queue_context.Lock_context ); heads = sem->Queue.Queue.heads; diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 948275b74c..4eaafa9036 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -195,10 +195,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread ) void *lock; Thread_queue_Queue *queue; - _Thread_queue_Context_initialize( - &queue_context, - _Thread_queue_MP_callout_do_nothing - ); + _Thread_queue_Context_initialize( &queue_context ); lock = _Thread_Lock_acquire( the_thread, &queue_context.Lock_context ); queue = the_thread->Wait.queue; @@ -206,6 +203,10 @@ void _Thread_queue_Extract( Thread_Control *the_thread ) if ( queue != NULL ) { _SMP_Assert( lock == &queue->Lock ); + _Thread_queue_Context_set_MP_callout( + &queue_context, + _Thread_queue_MP_callout_do_nothing + ); _Thread_queue_Extract_critical( queue, the_thread->Wait.operations, @@ -229,7 +230,8 @@ Thread_Control *_Thread_queue_Do_dequeue( Thread_queue_Context queue_context; Thread_Control *the_thread; - _Thread_queue_Context_initialize( &queue_context, mp_callout ); + _Thread_queue_Context_initialize( &queue_context ); + _Thread_queue_Context_set_MP_callout( &queue_context, mp_callout ); _Thread_queue_Acquire( the_thread_queue, &queue_context.Lock_context ); the_thread = _Thread_queue_First_locked( the_thread_queue, operations ); diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c index f9636e61c7..3bddac458d 100644 --- a/cpukit/score/src/threadrestart.c +++ b/cpukit/score/src/threadrestart.c @@ -118,7 +118,7 @@ static void _Thread_Wake_up_joining_threads( Thread_Control *the_thread ) join_context.exit_value = the_thread->Life.exit_value; #endif - _Thread_queue_Context_initialize( &join_context.Base, NULL ); + _Thread_queue_Context_initialize( &join_context.Base ); _Thread_queue_Acquire( &the_thread->Join_queue, &join_context.Base.Lock_context -- cgit v1.2.3