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/src | |
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/src')
-rw-r--r-- | cpukit/score/src/corebarrier.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/corebarrierrelease.c | 12 | ||||
-rw-r--r-- | cpukit/score/src/corebarrierwait.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremsg.c | 20 | ||||
-rw-r--r-- | cpukit/score/src/coremsgclose.c | 1 | ||||
-rw-r--r-- | cpukit/score/src/coremsgseize.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/coremsgsubmit.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremutex.c | 12 | ||||
-rw-r--r-- | cpukit/score/src/coremutexflush.c | 1 | ||||
-rw-r--r-- | cpukit/score/src/coremutexseize.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/coremutexsurrender.c | 10 | ||||
-rw-r--r-- | cpukit/score/src/corerwlock.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainread.c | 7 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockobtainwrite.c | 2 | ||||
-rw-r--r-- | cpukit/score/src/corerwlockrelease.c | 10 | ||||
-rw-r--r-- | cpukit/score/src/coresem.c | 23 | ||||
-rw-r--r-- | cpukit/score/src/mpci.c | 15 | ||||
-rw-r--r-- | cpukit/score/src/threadq.c | 16 | ||||
-rw-r--r-- | cpukit/score/src/threadqenqueue.c | 9 | ||||
-rw-r--r-- | cpukit/score/src/threadqfirst.c | 5 | ||||
-rw-r--r-- | cpukit/score/src/threadqflush.c | 20 |
21 files changed, 104 insertions, 82 deletions
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 ); |