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/thread.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/thread.c')
-rw-r--r-- | cpukit/score/src/thread.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c index ef9788ca41..e1d6d5c231 100644 --- a/cpukit/score/src/thread.c +++ b/cpukit/score/src/thread.c @@ -20,6 +20,7 @@ #include <rtems/score/threadimpl.h> #include <rtems/score/interr.h> +#include <rtems/score/wkspace.h> #define THREAD_OFFSET_ASSERT( field ) \ RTEMS_STATIC_ASSERT( \ @@ -40,6 +41,42 @@ THREAD_OFFSET_ASSERT( Timer ); THREAD_OFFSET_ASSERT( receive_packet ); #endif +void _Thread_Initialize_information( + Thread_Information *information, + Objects_APIs the_api, + uint16_t the_class, + uint32_t maximum, + bool is_string, + uint32_t maximum_name_length +#if defined(RTEMS_MULTIPROCESSING) + , + bool supports_global +#endif +) +{ + _Objects_Initialize_information( + &information->Objects, + the_api, + the_class, + maximum, + _Thread_Control_size, + is_string, + maximum_name_length + #if defined(RTEMS_MULTIPROCESSING) + , + supports_global, + NULL + #endif + ); + + _Freechain_Initialize( + &information->Free_thread_queue_heads, + _Workspace_Allocate_or_fatal_error, + _Objects_Maximum_per_allocation( maximum ), + sizeof( Thread_queue_Heads ) + ); +} + void _Thread_Handler_initialization(void) { rtems_stack_allocate_init_hook stack_allocate_init_hook = @@ -69,18 +106,16 @@ void _Thread_Handler_initialization(void) * per CPU in an SMP system. In addition, if this is a loosely * coupled multiprocessing system, account for the MPCI Server Thread. */ - _Objects_Initialize_information( + _Thread_Initialize_information( &_Thread_Internal_information, OBJECTS_INTERNAL_API, OBJECTS_INTERNAL_THREADS, _Thread_Get_maximum_internal_threads(), - _Thread_Control_size, /* size of this object's control block */ false, /* true if names for this object are strings */ 8 /* maximum length of each object's name */ #if defined(RTEMS_MULTIPROCESSING) , - false, /* true if this is a global object class */ - NULL /* Proxy extraction support callout */ + false /* true if this is a global object class */ #endif ); |