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/src/threadinitialize.c | |
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 'cpukit/score/src/threadinitialize.c')
-rw-r--r-- | cpukit/score/src/threadinitialize.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/cpukit/score/src/threadinitialize.c b/cpukit/score/src/threadinitialize.c index c6985f013b..9019e1fd30 100644 --- a/cpukit/score/src/threadinitialize.c +++ b/cpukit/score/src/threadinitialize.c @@ -30,7 +30,7 @@ #include <rtems/config.h> bool _Thread_Initialize( - Objects_Information *information, + Thread_Information *information, Thread_Control *the_thread, const Scheduler_Control *scheduler, void *stack_area, @@ -76,6 +76,7 @@ bool _Thread_Initialize( #endif the_thread->Start.tls_area = NULL; + the_thread->Wait.spare_heads = NULL; /* * Allocate and Initialize the stack for this thread. @@ -135,6 +136,20 @@ bool _Thread_Initialize( #endif /* + * Get thread queue heads + */ + the_thread->Wait.spare_heads = _Freechain_Get( + &information->Free_thread_queue_heads, + _Workspace_Allocate, + _Objects_Extend_size( &information->Objects ), + sizeof( *the_thread->Wait.spare_heads ) + ); + if ( the_thread->Wait.spare_heads == NULL ) { + goto failed; + } + _Chain_Initialize_empty( &the_thread->Wait.spare_heads->Free_chain ); + + /* * Initialize the thread timer */ _Watchdog_Preinitialize( &the_thread->Timer ); @@ -239,7 +254,7 @@ bool _Thread_Initialize( /* * Open the object */ - _Objects_Open( information, &the_thread->Object, name ); + _Objects_Open( &information->Objects, &the_thread->Object, name ); /* * We assume the Allocator Mutex is locked and dispatching is @@ -260,6 +275,11 @@ failed: _Workspace_Free( the_thread->Start.tls_area ); + _Freechain_Put( + &information->Free_thread_queue_heads, + the_thread->Wait.spare_heads + ); + #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE ) _Workspace_Free( fp_area ); #endif |