diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-06-24 15:43:19 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-07-23 08:01:13 +0200 |
commit | d7665823b208daefb6855591d808e1f3075cedcb (patch) | |
tree | 2080d79568c92ae40f9a49f3f82095307766cb1f /cpukit/score/include/rtems/score/threadqimpl.h | |
parent | score: Introduce Thread_queue_Queue (diff) | |
download | rtems-d7665823b208daefb6855591d808e1f3075cedcb.tar.bz2 |
score: Introduce Thread_queue_Heads
Move the storage for the thread queue heads to the threads. Each thread
provides a set of thread queue heads allocated from a dedicated memory
pool. In case a thread blocks on a queue, then it lends its heads to
the queue. In case the thread unblocks, then it takes a free set of
threads from the queue. Since a thread can block on at most one queue
this works. This mechanism is used in FreeBSD. The motivation for this
change is to reduce the memory demands of the synchronization objects.
On a 32-bit uni-processor configuration the Thread_queue_Control size is
now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced
the size as well).
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/include/rtems/score/threadqimpl.h | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h b/cpukit/score/include/rtems/score/threadqimpl.h index 330b18c5bf..e1060e4e82 100644 --- a/cpukit/score/include/rtems/score/threadqimpl.h +++ b/cpukit/score/include/rtems/score/threadqimpl.h @@ -33,6 +33,14 @@ extern "C" { */ /**@{*/ +RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_initialize( + Thread_queue_Queue *queue +) +{ + queue->heads = NULL; + _ISR_lock_Initialize( &queue->Lock, "Thread Queue" ); +} + RTEMS_INLINE_ROUTINE void _Thread_queue_Queue_acquire_critical( Thread_queue_Queue *queue, ISR_lock_Context *lock_context @@ -322,7 +330,13 @@ RTEMS_INLINE_ROUTINE Thread_Control *_Thread_queue_First_locked( Thread_queue_Control *the_thread_queue ) { - return ( *the_thread_queue->operations->first )( &the_thread_queue->Queue ); + Thread_queue_Heads *heads = the_thread_queue->Queue.heads; + + if ( heads != NULL ) { + return ( *the_thread_queue->operations->first )( heads ); + } else { + return NULL; + } } /** @@ -375,9 +389,7 @@ void _Thread_queue_Initialize( #if defined(RTEMS_SMP) #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \ .Queue = { \ - .Heads = { \ - .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \ - }, \ + .heads = NULL, \ .Lock = ISR_LOCK_INITIALIZER( name ), \ }, \ .operations = &_Thread_queue_Operations_FIFO \ @@ -385,33 +397,19 @@ void _Thread_queue_Initialize( #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \ .Queue = { \ - .Heads = { \ - .Priority = RBTREE_INITIALIZER_EMPTY( \ - designator.Queue.Heads.Priority \ - ) \ - }, \ + .heads = NULL, \ .Lock = ISR_LOCK_INITIALIZER( name ), \ }, \ .operations = &_Thread_queue_Operations_priority \ } #else #define THREAD_QUEUE_FIFO_INITIALIZER( designator, name ) { \ - .Queue = { \ - .Heads = { \ - .Fifo = CHAIN_INITIALIZER_EMPTY( designator.Queue.Heads.Fifo ) \ - } \ - }, \ + .Queue = { .heads = NULL }, \ .operations = &_Thread_queue_Operations_FIFO \ } #define THREAD_QUEUE_PRIORITY_INITIALIZER( designator, name ) { \ - .Queue = { \ - .Heads = { \ - .Priority = RBTREE_INITIALIZER_EMPTY( \ - designator.Queue.Heads.Priority \ - ) \ - } \ - }, \ + .Queue = { .heads = NULL }, \ .operations = &_Thread_queue_Operations_priority \ } #endif |