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/include | |
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/include')
-rw-r--r-- | cpukit/score/include/rtems/score/corebarrierimpl.h | 3 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremsg.h | 19 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremsgimpl.h | 30 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremutex.h | 6 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coremuteximpl.h | 6 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/corerwlockimpl.h | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coresem.h | 10 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/coresemimpl.h | 35 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadq.h | 14 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/threadqimpl.h | 92 |
10 files changed, 80 insertions, 137 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( |