diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-23 10:01:31 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-29 07:26:42 +0200 |
commit | 1e1a91ed11458ddbb27b94d0001d8f0fc2ef7a97 (patch) | |
tree | 5e7cb0e88da11528eb7fb4bae9148564c949d066 /cpukit/score | |
parent | libcpu/m68k/mcf5272/clock/ckinit.c: Fix warning by including <rtems/clockdrv.h> (diff) | |
download | rtems-1e1a91ed11458ddbb27b94d0001d8f0fc2ef7a97.tar.bz2 |
score: Remove Thread_queue_Queue::operations field
Remove the Thread_queue_Queue::operations field to reduce the size of
this structure. Add a thread queue operations parameter to the
_Thread_queue_First(), _Thread_queue_First_locked(),
_Thread_queue_Enqueue(), _Thread_queue_Dequeue() and
_Thread_queue_Flush() functions. This is a preparation patch to reduce
the size of several synchronization objects.
Diffstat (limited to 'cpukit/score')
31 files changed, 184 insertions, 219 deletions
diff --git a/cpukit/score/include/rtems/score/corebarrierimpl.h b/cpukit/score/include/rtems/score/corebarrierimpl.h index e8b330dcb6..87ea545747 100644 --- a/cpukit/score/include/rtems/score/corebarrierimpl.h +++ b/cpukit/score/include/rtems/score/corebarrierimpl.h @@ -62,6 +62,8 @@ typedef enum { */ #define CORE_BARRIER_STATUS_LAST CORE_BARRIER_TIMEOUT +#define CORE_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + /** * The following type defines the callout which the API provides * to support global/multiprocessor operations on barriers. @@ -150,6 +152,7 @@ uint32_t _CORE_barrier_Release( #define _CORE_barrier_Flush( _the_barrier, _remote_extract_callout, _status) \ _Thread_queue_Flush( \ &((_the_barrier)->Wait_queue), \ + CORE_BARRIER_TQ_OPERATIONS, \ (_remote_extract_callout), \ (_status) \ ) diff --git a/cpukit/score/include/rtems/score/coremsg.h b/cpukit/score/include/rtems/score/coremsg.h index 84a3a97f0e..27443462fe 100644 --- a/cpukit/score/include/rtems/score/coremsg.h +++ b/cpukit/score/include/rtems/score/coremsg.h @@ -109,17 +109,6 @@ typedef enum { CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY } CORE_message_queue_Disciplines; -/** - * @brief Control block used to manage the attributes of each message queue. - * - * The following defines the control block used to manage the - * attributes of each message queue. - */ -typedef struct { - /** This field specifies the order in which blocking tasks will be ordered. */ - CORE_message_queue_Disciplines discipline; -} CORE_message_queue_Attributes; - #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) /** * @brief Type for a notification handler. @@ -142,10 +131,12 @@ typedef struct { * which are blocked waiting to receive a message from this queue. */ Thread_queue_Control Wait_queue; - /** This element is the set of attributes which define this instance's - * behavior. + + /** + * @brief The thread queue operations according to the blocking discipline. */ - CORE_message_queue_Attributes Attributes; + const Thread_queue_Operations *operations; + /** This element is maximum number of messages which may be pending * at any given time. */ diff --git a/cpukit/score/include/rtems/score/coremsgimpl.h b/cpukit/score/include/rtems/score/coremsgimpl.h index 382ce92815..407d3aee15 100644 --- a/cpukit/score/include/rtems/score/coremsgimpl.h +++ b/cpukit/score/include/rtems/score/coremsgimpl.h @@ -122,8 +122,7 @@ typedef void ( *CORE_message_queue_API_mp_support_callout )( * based on the parameters passed. * * @param[in] the_message_queue points to the message queue to initialize - * @param[in] the_message_queue_attributes points to the attributes that - * will be used with this message queue instance + * @param[in] discipline the blocking discipline * @param[in] maximum_pending_messages is the maximum number of messages * that will be allowed to pend at any given time * @param[in] maximum_message_size is the size of largest message that @@ -134,10 +133,10 @@ typedef void ( *CORE_message_queue_API_mp_support_callout )( * messages cannot be allocated. */ bool _CORE_message_queue_Initialize( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Attributes *the_message_queue_attributes, - uint32_t maximum_pending_messages, - size_t maximum_message_size + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Disciplines discipline, + uint32_t maximum_pending_messages, + size_t maximum_message_size ); /** @@ -513,18 +512,6 @@ RTEMS_INLINE_ROUTINE _Chain_Get_unprotected( &the_message_queue->Pending_messages ); } -/** - * This function returns true if the priority attribute is - * enabled in the attribute_set and false otherwise. - */ -RTEMS_INLINE_ROUTINE bool _CORE_message_queue_Is_priority( - CORE_message_queue_Attributes *the_attribute -) -{ - return - (the_attribute->discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY); -} - #if defined(RTEMS_SCORE_COREMSG_ENABLE_NOTIFICATION) /** * This function returns true if notification is enabled on this message @@ -584,7 +571,10 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( * There must be no pending messages if there is a thread waiting to * receive a message. */ - the_thread = _Thread_queue_First_locked( &the_message_queue->Wait_queue ); + the_thread = _Thread_queue_First_locked( + &the_message_queue->Wait_queue, + the_message_queue->operations + ); if ( the_thread == NULL ) { return NULL; } @@ -600,7 +590,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_CORE_message_queue_Dequeue_receiver( _Thread_queue_Extract_critical( &the_message_queue->Wait_queue.Queue, - the_message_queue->Wait_queue.operations, + the_message_queue->operations, the_thread, lock_context ); diff --git a/cpukit/score/include/rtems/score/coremutex.h b/cpukit/score/include/rtems/score/coremutex.h index ccf6066740..c9b30dd956 100644 --- a/cpukit/score/include/rtems/score/coremutex.h +++ b/cpukit/score/include/rtems/score/coremutex.h @@ -151,6 +151,12 @@ typedef struct { * which are blocked waiting to lock the mutex. */ Thread_queue_Control Wait_queue; + + /** + * @brief The thread queue operations according to the blocking discipline. + */ + const Thread_queue_Operations *operations; + /** This element is the set of attributes which define this instance's * behavior. */ diff --git a/cpukit/score/include/rtems/score/coremuteximpl.h b/cpukit/score/include/rtems/score/coremuteximpl.h index f57fdfcfd5..b22f4a7d5c 100644 --- a/cpukit/score/include/rtems/score/coremuteximpl.h +++ b/cpukit/score/include/rtems/score/coremuteximpl.h @@ -392,7 +392,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_fifo( * */ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority( - CORE_mutex_Attributes *the_attribute + const CORE_mutex_Attributes *the_attribute ) { return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY; @@ -410,7 +410,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority( * @retval false The mutex is not using priority inheritance. */ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_inherit_priority( - CORE_mutex_Attributes *the_attribute + const CORE_mutex_Attributes *the_attribute ) { return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT; @@ -428,7 +428,7 @@ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_inherit_priority( * @retval false The mutex is not using priority ceiling. */ RTEMS_INLINE_ROUTINE bool _CORE_mutex_Is_priority_ceiling( - CORE_mutex_Attributes *the_attribute + const CORE_mutex_Attributes *the_attribute ) { return the_attribute->discipline == CORE_MUTEX_DISCIPLINES_PRIORITY_CEILING; diff --git a/cpukit/score/include/rtems/score/corerwlockimpl.h b/cpukit/score/include/rtems/score/corerwlockimpl.h index e619574d89..e41c6995aa 100644 --- a/cpukit/score/include/rtems/score/corerwlockimpl.h +++ b/cpukit/score/include/rtems/score/corerwlockimpl.h @@ -33,6 +33,8 @@ extern "C" { */ /**@{**/ +#define CORE_RWLOCK_TQ_OPERATIONS &_Thread_queue_Operations_FIFO + /** * The following type defines the callout which the API provides * to support global/multiprocessor operations on RWLocks. diff --git a/cpukit/score/include/rtems/score/coresem.h b/cpukit/score/include/rtems/score/coresem.h index 5f871f063e..44e17c3d20 100644 --- a/cpukit/score/include/rtems/score/coresem.h +++ b/cpukit/score/include/rtems/score/coresem.h @@ -56,10 +56,6 @@ typedef enum { typedef struct { /** This element indicates the maximum count this semaphore may have. */ uint32_t maximum_count; - /** This field indicates whether threads waiting on the semaphore block in - * FIFO or priority order. - */ - CORE_semaphore_Disciplines discipline; } CORE_semaphore_Attributes; /** @@ -71,6 +67,12 @@ typedef struct { * which are blocked waiting to obtain the semaphore. */ Thread_queue_Control Wait_queue; + + /** + * @brief The thread queue operations according to the blocking discipline. + */ + const Thread_queue_Operations *operations; + /** This element is the set of attributes which define this instance's * behavior. */ diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h index a6a30bcc15..365345a219 100644 --- a/cpukit/score/include/rtems/score/coresemimpl.h +++ b/cpukit/score/include/rtems/score/coresemimpl.h @@ -86,13 +86,15 @@ typedef void ( *CORE_semaphore_API_mp_support_callout )( * This routine initializes the semaphore based on the parameters passed. * * @param[in] the_semaphore is the semaphore to initialize - * @param[in] the_semaphore_attributes define the behavior of this instance + * @param[in] discipline the blocking discipline + * @param[in] maximum_count the maximum count * @param[in] initial_value is the initial count of the semaphore */ void _CORE_semaphore_Initialize( - CORE_semaphore_Control *the_semaphore, - const CORE_semaphore_Attributes *the_semaphore_attributes, - uint32_t initial_value + CORE_semaphore_Control *the_semaphore, + CORE_semaphore_Disciplines discipline, + uint32_t maximum_count, + uint32_t initial_value ); RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy( @@ -133,7 +135,10 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender( _Thread_queue_Acquire_critical( &the_semaphore->Wait_queue, lock_context ); - the_thread = _Thread_queue_First_locked( &the_semaphore->Wait_queue ); + the_thread = _Thread_queue_First_locked( + &the_semaphore->Wait_queue, + the_semaphore->operations + ); if ( the_thread != NULL ) { #if defined(RTEMS_MULTIPROCESSING) _Thread_Dispatch_disable(); @@ -141,7 +146,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender( _Thread_queue_Extract_critical( &the_semaphore->Wait_queue.Queue, - the_semaphore->Wait_queue.operations, + the_semaphore->operations, the_thread, lock_context ); @@ -187,27 +192,13 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Flush( { _Thread_queue_Flush( &the_semaphore->Wait_queue, + the_semaphore->operations, remote_extract_callout, status ); } /** - * This function returns true if the priority attribute is - * enabled in the @a attribute_set and false otherwise. - * - * @param[in] the_attribute is the attribute set to test - * - * @return true if the priority attribute is enabled - */ -RTEMS_INLINE_ROUTINE bool _CORE_semaphore_Is_priority( - const CORE_semaphore_Attributes *the_attribute -) -{ - return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ); -} - -/** * This routine returns the current count associated with the semaphore. * * @param[in] the_semaphore is the semaphore to obtain the count of @@ -265,7 +256,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize( executing->Wait.id = id; _Thread_queue_Enqueue_critical( &the_semaphore->Wait_queue.Queue, - the_semaphore->Wait_queue.operations, + the_semaphore->operations, executing, STATES_WAITING_FOR_SEMAPHORE, timeout, diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h index cc07daed57..fbd53293ee 100644 --- a/cpukit/score/include/rtems/score/threadq.h +++ b/cpukit/score/include/rtems/score/threadq.h @@ -244,15 +244,6 @@ typedef struct { } Thread_queue_Operations; /** - * The following enumerated type details all of the disciplines - * supported by the Thread Queue Handler. - */ -typedef enum { - THREAD_QUEUE_DISCIPLINE_FIFO, /* FIFO queue discipline */ - THREAD_QUEUE_DISCIPLINE_PRIORITY /* PRIORITY queue discipline */ -} Thread_queue_Disciplines; - -/** * This is the structure used to manage sets of tasks which are blocked * waiting to acquire a resource. */ @@ -265,11 +256,6 @@ typedef struct { #if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) SMP_lock_Stats Lock_stats; #endif - - /** - * @brief The operations for the actual thread queue. - */ - const Thread_queue_Operations *operations; } Thread_queue_Control; /**@}*/ diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index 510f886844..82f7dc1796 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -173,7 +173,8 @@ typedef void ( *Thread_queue_Flush_callout )( * + single case */ Thread_Control *_Thread_queue_Dequeue( - Thread_queue_Control *the_thread_queue + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations ); /** @@ -196,6 +197,8 @@ Thread_Control *_Thread_queue_Dequeue( * #include <rtems/score/threadqimpl.h> * #include <rtems/score/statesimpl.h> * + * #define MUTEX_TQ_OPERATIONS &_Thread_queue_Operations_priority + * * typedef struct { * Thread_queue_Control Queue; * Thread_Control *owner; @@ -216,7 +219,7 @@ Thread_Control *_Thread_queue_Dequeue( * } else { * _Thread_queue_Enqueue_critical( * &mutex->Queue.Queue, - * mutex->Queue.operations, + * MUTEX_TQ_OPERATIONS, * executing, * STATES_WAITING_FOR_MUTEX, * WATCHDOG_NO_TIMEOUT, @@ -251,11 +254,12 @@ void _Thread_queue_Enqueue_critical( * _Thread_queue_Enqueue_critical(). */ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue( - Thread_queue_Control *the_thread_queue, - Thread_Control *the_thread, - States_Control state, - Watchdog_Interval timeout, - uint32_t timeout_code + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations, + Thread_Control *the_thread, + States_Control state, + Watchdog_Interval timeout, + uint32_t timeout_code ) { ISR_lock_Context lock_context; @@ -263,7 +267,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue( _Thread_queue_Acquire( the_thread_queue, &lock_context ); _Thread_queue_Enqueue_critical( &the_thread_queue->Queue, - the_thread_queue->operations, + operations, the_thread, state, timeout, @@ -400,19 +404,21 @@ void _Thread_queue_Extract_with_proxy( * lock is not released. * * @param[in] the_thread_queue The thread queue. + * @param[in] operations The thread queue operations. * * @retval NULL No thread is present on the thread queue. * @retval first The first thread on the thread queue according to the enqueue * order. */ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked( - Thread_queue_Control *the_thread_queue + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations ) { Thread_queue_Heads *heads = the_thread_queue->Queue.heads; if ( heads != NULL ) { - return ( *the_thread_queue->operations->first )( heads ); + return ( *operations->first )( heads ); } else { return NULL; } @@ -429,7 +435,8 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked( * order. */ Thread_Control *_Thread_queue_First( - Thread_queue_Control *the_thread_queue + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations ); /** @@ -439,76 +446,41 @@ Thread_Control *_Thread_queue_First( * and cancels any associated timeouts. * * @param[in] the_thread_queue is the pointer to a threadq header + * @param[in] operations The thread queue operations. * @param[in] remote_extract_callout points to a method to invoke to * invoke when a remote thread is unblocked * @param[in] status is the status which will be returned to * all unblocked threads */ void _Thread_queue_Flush( - Thread_queue_Control *the_thread_queue, - Thread_queue_Flush_callout remote_extract_callout, - uint32_t status + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations, + Thread_queue_Flush_callout remote_extract_callout, + uint32_t status ); -/** - * @brief Initialize the_thread_queue. - * - * This routine initializes the_thread_queue based on the - * discipline indicated in attribute_set. The state set on - * threads which block on the_thread_queue is state. - * - * @param[in] the_thread_queue is the pointer to a threadq header - * @param[in] the_discipline is the queueing discipline - */ -void _Thread_queue_Initialize( - Thread_queue_Control *the_thread_queue, - Thread_queue_Disciplines the_discipline -); +void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue ); #if defined(RTEMS_SMP) && defined(RTEMS_PROFILING) - #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \ + #define THREAD_QUEUE_INITIALIZER( name ) \ + { \ .Queue = { \ .heads = NULL, \ .Lock = SMP_TICKET_LOCK_INITIALIZER, \ }, \ - .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \ - .operations = &_Thread_queue_Operations_FIFO \ - } - - #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \ - .Queue = { \ - .heads = NULL, \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - }, \ - .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ), \ - .operations = &_Thread_queue_Operations_priority \ + .Lock_stats = SMP_LOCK_STATS_INITIALIZER( name ) \ } #elif defined(RTEMS_SMP) - #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \ + #define THREAD_QUEUE_INITIALIZER( name ) \ + { \ .Queue = { \ .heads = NULL, \ .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - }, \ - .operations = &_Thread_queue_Operations_FIFO \ - } - - #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \ - .Queue = { \ - .heads = NULL, \ - .Lock = SMP_TICKET_LOCK_INITIALIZER, \ - }, \ - .operations = &_Thread_queue_Operations_priority \ + } \ } #else - #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \ - .Queue = { .heads = NULL }, \ - .operations = &_Thread_queue_Operations_FIFO \ - } - - #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \ - .Queue = { .heads = NULL }, \ - .operations = &_Thread_queue_Operations_priority \ - } + #define THREAD_QUEUE_INITIALIZER( name ) \ + { .Queue = { .heads = NULL } } #endif RTEMS_INLINE_ROUTINE void _Thread_queue_Destroy( diff --git a/cpukit/score/src/corebarrier.c b/cpukit/score/src/corebarrier.c index eddf901934..5313a0f6c8 100644 --- a/cpukit/score/src/corebarrier.c +++ b/cpukit/score/src/corebarrier.c @@ -30,8 +30,5 @@ void _CORE_barrier_Initialize( the_barrier->Attributes = *the_barrier_attributes; the_barrier->number_of_waiting_threads = 0; - _Thread_queue_Initialize( - &the_barrier->Wait_queue, - THREAD_QUEUE_DISCIPLINE_FIFO - ); + _Thread_queue_Initialize( &the_barrier->Wait_queue ); } diff --git a/cpukit/score/src/corebarrierrelease.c b/cpukit/score/src/corebarrierrelease.c index c6d29b9f03..ba02301616 100644 --- a/cpukit/score/src/corebarrierrelease.c +++ b/cpukit/score/src/corebarrierrelease.c @@ -23,6 +23,16 @@ #include <rtems/score/objectimpl.h> #include <rtems/score/threadqimpl.h> +static Thread_Control *_CORE_barrier_Dequeue( + CORE_barrier_Control *the_barrier +) +{ + return _Thread_queue_Dequeue( + &the_barrier->Wait_queue, + CORE_BARRIER_TQ_OPERATIONS + ); +} + uint32_t _CORE_barrier_Release( CORE_barrier_Control *the_barrier, #if defined(RTEMS_MULTIPROCESSING) @@ -38,7 +48,7 @@ uint32_t _CORE_barrier_Release( uint32_t count; count = 0; - while ( (the_thread = _Thread_queue_Dequeue(&the_barrier->Wait_queue)) ) { + while ( ( the_thread = _CORE_barrier_Dequeue( the_barrier ) ) ) { #if defined(RTEMS_MULTIPROCESSING) if ( !_Objects_Is_local_id( the_thread->Object.id ) ) (*api_barrier_mp_support) ( the_thread, id ); diff --git a/cpukit/score/src/corebarrierwait.c b/cpukit/score/src/corebarrierwait.c index b7f424d03d..4fadc03d9b 100644 --- a/cpukit/score/src/corebarrierwait.c +++ b/cpukit/score/src/corebarrierwait.c @@ -51,7 +51,7 @@ void _CORE_barrier_Wait( _Thread_queue_Enqueue_critical( &the_barrier->Wait_queue.Queue, - the_barrier->Wait_queue.operations, + CORE_BARRIER_TQ_OPERATIONS, executing, STATES_WAITING_FOR_BARRIER, timeout, diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c index ae2bc753c7..b184585964 100644 --- a/cpukit/score/src/coremsg.c +++ b/cpukit/score/src/coremsg.c @@ -43,10 +43,10 @@ static inline bool size_t_mult32_with_overflow( } bool _CORE_message_queue_Initialize( - CORE_message_queue_Control *the_message_queue, - CORE_message_queue_Attributes *the_message_queue_attributes, - uint32_t maximum_pending_messages, - size_t maximum_message_size + CORE_message_queue_Control *the_message_queue, + CORE_message_queue_Disciplines discipline, + uint32_t maximum_pending_messages, + size_t maximum_message_size ) { size_t message_buffering_required = 0; @@ -108,11 +108,13 @@ bool _CORE_message_queue_Initialize( _Chain_Initialize_empty( &the_message_queue->Pending_messages ); - _Thread_queue_Initialize( - &the_message_queue->Wait_queue, - _CORE_message_queue_Is_priority( the_message_queue_attributes ) ? - THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO - ); + _Thread_queue_Initialize( &the_message_queue->Wait_queue ); + + if ( discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY ) { + the_message_queue->operations = &_Thread_queue_Operations_priority; + } else { + the_message_queue->operations = &_Thread_queue_Operations_FIFO; + } return true; } diff --git a/cpukit/score/src/coremsgclose.c b/cpukit/score/src/coremsgclose.c index e0d370d512..60b6c9225b 100644 --- a/cpukit/score/src/coremsgclose.c +++ b/cpukit/score/src/coremsgclose.c @@ -36,6 +36,7 @@ void _CORE_message_queue_Close( _Thread_queue_Flush( &the_message_queue->Wait_queue, + the_message_queue->operations, remote_extract_callout, status ); diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c index b6ba8e9e32..9d26fb1235 100644 --- a/cpukit/score/src/coremsgseize.c +++ b/cpukit/score/src/coremsgseize.c @@ -74,7 +74,8 @@ void _CORE_message_queue_Seize( * then we can avoid this dequeue. */ the_thread = _Thread_queue_First_locked( - &the_message_queue->Wait_queue + &the_message_queue->Wait_queue, + the_message_queue->operations ); if ( the_thread == NULL ) { _CORE_message_queue_Free_message_buffer( @@ -108,7 +109,7 @@ void _CORE_message_queue_Seize( ); _Thread_queue_Extract_critical( &the_message_queue->Wait_queue.Queue, - the_message_queue->Wait_queue.operations, + the_message_queue->operations, the_thread, lock_context ); @@ -133,7 +134,7 @@ void _CORE_message_queue_Seize( _Thread_queue_Enqueue_critical( &the_message_queue->Wait_queue.Queue, - the_message_queue->Wait_queue.operations, + the_message_queue->operations, executing, STATES_WAITING_FOR_MESSAGE, timeout, diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c index d068cc4a05..5f61c5e644 100644 --- a/cpukit/score/src/coremsgsubmit.c +++ b/cpukit/score/src/coremsgsubmit.c @@ -133,7 +133,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit( _Thread_queue_Enqueue_critical( &the_message_queue->Wait_queue.Queue, - the_message_queue->Wait_queue.operations, + the_message_queue->operations, executing, STATES_WAITING_FOR_MESSAGE, timeout, diff --git a/cpukit/score/src/coremutex.c b/cpukit/score/src/coremutex.c index 6bb535a8ec..88d487ca4b 100644 --- a/cpukit/score/src/coremutex.c +++ b/cpukit/score/src/coremutex.c @@ -86,11 +86,13 @@ CORE_mutex_Status _CORE_mutex_Initialize( the_mutex->holder = NULL; } - _Thread_queue_Initialize( - &the_mutex->Wait_queue, - _CORE_mutex_Is_fifo( the_mutex_attributes ) ? - THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY - ); + _Thread_queue_Initialize( &the_mutex->Wait_queue ); + + if ( _CORE_mutex_Is_priority( the_mutex_attributes ) ) { + the_mutex->operations = &_Thread_queue_Operations_priority; + } else { + the_mutex->operations = &_Thread_queue_Operations_FIFO; + } return CORE_MUTEX_STATUS_SUCCESSFUL; } diff --git a/cpukit/score/src/coremutexflush.c b/cpukit/score/src/coremutexflush.c index 3a6090102d..c487652daa 100644 --- a/cpukit/score/src/coremutexflush.c +++ b/cpukit/score/src/coremutexflush.c @@ -31,6 +31,7 @@ void _CORE_mutex_Flush( { _Thread_queue_Flush( &the_mutex->Wait_queue, + the_mutex->operations, remote_extract_callout, status ); diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c index 8059659a42..fa45151d0b 100644 --- a/cpukit/score/src/coremutexseize.c +++ b/cpukit/score/src/coremutexseize.c @@ -84,7 +84,7 @@ void _CORE_mutex_Seize_interrupt_blocking( _Thread_queue_Enqueue_critical( &the_mutex->Wait_queue.Queue, - the_mutex->Wait_queue.operations, + the_mutex->operations, executing, STATES_WAITING_FOR_MUTEX, timeout, diff --git a/cpukit/score/src/coremutexsurrender.c b/cpukit/score/src/coremutexsurrender.c index b4e69c8698..744adc5eb8 100644 --- a/cpukit/score/src/coremutexsurrender.c +++ b/cpukit/score/src/coremutexsurrender.c @@ -178,7 +178,13 @@ CORE_mutex_Status _CORE_mutex_Surrender( * Now we check if another thread was waiting for this mutex. If so, * transfer the mutex to that thread. */ - if ( ( the_thread = _Thread_queue_First_locked( &the_mutex->Wait_queue ) ) ) { + if ( + ( the_thread = _Thread_queue_First_locked( + &the_mutex->Wait_queue, + the_mutex->operations + ) + ) + ) { bool unblock; /* @@ -189,7 +195,7 @@ CORE_mutex_Status _CORE_mutex_Surrender( */ unblock = _Thread_queue_Extract_locked( &the_mutex->Wait_queue.Queue, - the_mutex->Wait_queue.operations, + the_mutex->operations, the_thread ); diff --git a/cpukit/score/src/corerwlock.c b/cpukit/score/src/corerwlock.c index 8b74c4119c..23bb5e29e3 100644 --- a/cpukit/score/src/corerwlock.c +++ b/cpukit/score/src/corerwlock.c @@ -34,8 +34,5 @@ void _CORE_RWLock_Initialize( the_rwlock->number_of_readers = 0; the_rwlock->current_state = CORE_RWLOCK_UNLOCKED; - _Thread_queue_Initialize( - &the_rwlock->Wait_queue, - THREAD_QUEUE_DISCIPLINE_FIFO - ); + _Thread_queue_Initialize( &the_rwlock->Wait_queue ); } diff --git a/cpukit/score/src/corerwlockobtainread.c b/cpukit/score/src/corerwlockobtainread.c index 73ebddf2df..97d7b9e513 100644 --- a/cpukit/score/src/corerwlockobtainread.c +++ b/cpukit/score/src/corerwlockobtainread.c @@ -51,7 +51,10 @@ void _CORE_RWLock_Obtain_for_reading( case CORE_RWLOCK_LOCKED_FOR_READING: { Thread_Control *waiter; - waiter = _Thread_queue_First_locked( &the_rwlock->Wait_queue ); + waiter = _Thread_queue_First_locked( + &the_rwlock->Wait_queue, + CORE_RWLOCK_TQ_OPERATIONS + ); if ( !waiter ) { the_rwlock->number_of_readers += 1; _Thread_queue_Release( &the_rwlock->Wait_queue, &lock_context ); @@ -84,7 +87,7 @@ void _CORE_RWLock_Obtain_for_reading( _Thread_queue_Enqueue_critical( &the_rwlock->Wait_queue.Queue, - the_rwlock->Wait_queue.operations, + CORE_RWLOCK_TQ_OPERATIONS, executing, STATES_WAITING_FOR_RWLOCK, timeout, diff --git a/cpukit/score/src/corerwlockobtainwrite.c b/cpukit/score/src/corerwlockobtainwrite.c index b5b31dcf27..28de842f9d 100644 --- a/cpukit/score/src/corerwlockobtainwrite.c +++ b/cpukit/score/src/corerwlockobtainwrite.c @@ -74,7 +74,7 @@ void _CORE_RWLock_Obtain_for_writing( _Thread_queue_Enqueue_critical( &the_rwlock->Wait_queue.Queue, - the_rwlock->Wait_queue.operations, + CORE_RWLOCK_TQ_OPERATIONS, executing, STATES_WAITING_FOR_RWLOCK, timeout, diff --git a/cpukit/score/src/corerwlockrelease.c b/cpukit/score/src/corerwlockrelease.c index bd39213c87..36fcf76088 100644 --- a/cpukit/score/src/corerwlockrelease.c +++ b/cpukit/score/src/corerwlockrelease.c @@ -64,7 +64,10 @@ CORE_RWLock_Status _CORE_RWLock_Release( the_rwlock->current_state = CORE_RWLOCK_UNLOCKED; _ISR_Enable( level ); - next = _Thread_queue_Dequeue( &the_rwlock->Wait_queue ); + next = _Thread_queue_Dequeue( + &the_rwlock->Wait_queue, + CORE_RWLOCK_TQ_OPERATIONS + ); if ( next ) { if ( next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) { @@ -82,7 +85,10 @@ CORE_RWLock_Status _CORE_RWLock_Release( * Now see if more readers can be let go. */ while ( 1 ) { - next = _Thread_queue_First( &the_rwlock->Wait_queue ); + next = _Thread_queue_First( + &the_rwlock->Wait_queue, + CORE_RWLOCK_TQ_OPERATIONS + ); if ( !next || next->Wait.option == CORE_RWLOCK_THREAD_WAITING_FOR_WRITE ) return CORE_RWLOCK_SUCCESSFUL; diff --git a/cpukit/score/src/coresem.c b/cpukit/score/src/coresem.c index 2475c349a7..db2d47f872 100644 --- a/cpukit/score/src/coresem.c +++ b/cpukit/score/src/coresem.c @@ -21,18 +21,21 @@ #include <rtems/score/coresemimpl.h> void _CORE_semaphore_Initialize( - CORE_semaphore_Control *the_semaphore, - const CORE_semaphore_Attributes *the_semaphore_attributes, - uint32_t initial_value + CORE_semaphore_Control *the_semaphore, + CORE_semaphore_Disciplines discipline, + uint32_t maximum_count, + uint32_t initial_value ) { - the_semaphore->Attributes = *the_semaphore_attributes; - the_semaphore->count = initial_value; + the_semaphore->Attributes.maximum_count = maximum_count; + the_semaphore->count = initial_value; - _Thread_queue_Initialize( - &the_semaphore->Wait_queue, - _CORE_semaphore_Is_priority( the_semaphore_attributes ) ? - THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO - ); + _Thread_queue_Initialize( &the_semaphore->Wait_queue ); + + if ( discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY ) { + the_semaphore->operations = &_Thread_queue_Operations_priority; + } else { + the_semaphore->operations = &_Thread_queue_Operations_FIFO; + } } diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c index 3929d78a09..8e93d74dd9 100644 --- a/cpukit/score/src/mpci.c +++ b/cpukit/score/src/mpci.c @@ -54,7 +54,8 @@ const rtems_multiprocessing_table */ CORE_semaphore_Control _MPCI_Semaphore; -Thread_queue_Control _MPCI_Remote_blocked_threads; +Thread_queue_Control _MPCI_Remote_blocked_threads = + THREAD_QUEUE_INITIALIZER( "MPCI Remote Blocked Threads" ); MPCI_Control *_MPCI_table; @@ -85,7 +86,6 @@ static void _MPCI_Handler_early_initialization( void ) static void _MPCI_Handler_initialization( void ) { - CORE_semaphore_Attributes attributes; MPCI_Control *users_mpci_table; _Objects_MP_Handler_initialization(); @@ -117,18 +117,12 @@ static void _MPCI_Handler_initialization( void ) * Create the counting semaphore used by the MPCI Receive Server. */ - attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO; - _CORE_semaphore_Initialize( &_MPCI_Semaphore, - &attributes, /* the_semaphore_attributes */ + CORE_SEMAPHORE_DISCIPLINES_FIFO, + 0xffffffff, 0 /* initial_value */ ); - - _Thread_queue_Initialize( - &_MPCI_Remote_blocked_threads, - THREAD_QUEUE_DISCIPLINE_FIFO - ); } static void _MPCI_Create_server( void ) @@ -262,6 +256,7 @@ uint32_t _MPCI_Send_request_packet ( _Thread_queue_Enqueue( &_MPCI_Remote_blocked_threads, + &_Thread_queue_Operations_FIFO, executing, STATES_WAITING_FOR_RPC_REPLY | extra_state, the_packet->timeout, diff --git a/cpukit/score/src/threadq.c b/cpukit/score/src/threadq.c index 372a07d64c..f8f18ed41f 100644 --- a/cpukit/score/src/threadq.c +++ b/cpukit/score/src/threadq.c @@ -79,22 +79,8 @@ RBTree_Compare_result _Thread_queue_Compare_priority( return ( left_prio > right_prio ) - ( left_prio < right_prio ); } -void _Thread_queue_Initialize( - Thread_queue_Control *the_thread_queue, - Thread_queue_Disciplines the_discipline -) +void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue ) { - const Thread_queue_Operations *operations; - - if ( the_discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY ) { - operations = &_Thread_queue_Operations_priority; - } else { - _Assert( the_discipline == THREAD_QUEUE_DISCIPLINE_FIFO ); - operations = &_Thread_queue_Operations_FIFO; - } - - the_thread_queue->operations = operations; - _Thread_queue_Queue_initialize( &the_thread_queue->Queue ); #if defined(RTEMS_SMP) _SMP_lock_Stats_initialize( &the_thread_queue->Lock_stats, "Thread Queue" ); diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c index 07618fc800..e7751359d7 100644 --- a/cpukit/score/src/threadqenqueue.c +++ b/cpukit/score/src/threadqenqueue.c @@ -193,21 +193,24 @@ void _Thread_queue_Extract( Thread_Control *the_thread ) } } -Thread_Control *_Thread_queue_Dequeue( Thread_queue_Control *the_thread_queue ) +Thread_Control *_Thread_queue_Dequeue( + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations +) { ISR_lock_Context lock_context; Thread_Control *the_thread; _Thread_queue_Acquire( the_thread_queue, &lock_context ); - the_thread = _Thread_queue_First_locked( the_thread_queue ); + the_thread = _Thread_queue_First_locked( the_thread_queue, operations ); if ( the_thread != NULL ) { _SMP_Assert( the_thread->Lock.current == &the_thread_queue->Queue.Lock ); _Thread_queue_Extract_critical( &the_thread_queue->Queue, - the_thread_queue->operations, + operations, the_thread, &lock_context ); diff --git a/cpukit/score/src/threadqfirst.c b/cpukit/score/src/threadqfirst.c index c46f005c3e..790ea8c59f 100644 --- a/cpukit/score/src/threadqfirst.c +++ b/cpukit/score/src/threadqfirst.c @@ -21,14 +21,15 @@ #include <rtems/score/threadqimpl.h> Thread_Control *_Thread_queue_First( - Thread_queue_Control *the_thread_queue + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations ) { Thread_Control *the_thread; ISR_lock_Context lock_context; _Thread_queue_Acquire( the_thread_queue, &lock_context ); - the_thread = _Thread_queue_First_locked( the_thread_queue ); + the_thread = _Thread_queue_First_locked( the_thread_queue, operations ); _Thread_queue_Release( the_thread_queue, &lock_context ); return the_thread; diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c index 8dca3f9fd4..13d2a5b1ac 100644 --- a/cpukit/score/src/threadqflush.c +++ b/cpukit/score/src/threadqflush.c @@ -22,13 +22,14 @@ #include <rtems/score/objectimpl.h> void _Thread_queue_Flush( - Thread_queue_Control *the_thread_queue, + Thread_queue_Control *the_thread_queue, + const Thread_queue_Operations *operations, #if defined(RTEMS_MULTIPROCESSING) - Thread_queue_Flush_callout remote_extract_callout, + Thread_queue_Flush_callout remote_extract_callout, #else - Thread_queue_Flush_callout remote_extract_callout RTEMS_UNUSED, + Thread_queue_Flush_callout remote_extract_callout RTEMS_UNUSED, #endif - uint32_t status + uint32_t status ) { ISR_lock_Context lock_context; @@ -36,7 +37,14 @@ void _Thread_queue_Flush( _Thread_queue_Acquire( the_thread_queue, &lock_context ); - while ( (the_thread = _Thread_queue_First_locked( the_thread_queue ) ) ) { + while ( + ( + the_thread = _Thread_queue_First_locked( + the_thread_queue, + operations + ) + ) + ) { #if defined(RTEMS_MULTIPROCESSING) if ( _Objects_Is_local_id( the_thread->Object.id ) ) #endif @@ -44,7 +52,7 @@ void _Thread_queue_Flush( _Thread_queue_Extract_critical( &the_thread_queue->Queue, - the_thread_queue->operations, + operations, the_thread, &lock_context ); |