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/posix | |
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/posix')
-rw-r--r-- | cpukit/posix/include/rtems/posix/pthreadimpl.h | 6 | ||||
-rw-r--r-- | cpukit/posix/src/killinfo.c | 47 | ||||
-rw-r--r-- | cpukit/posix/src/pthread.c | 6 |
3 files changed, 30 insertions, 29 deletions
diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h b/cpukit/posix/include/rtems/posix/pthreadimpl.h index d0dc330643..f95ac9cf94 100644 --- a/cpukit/posix/include/rtems/posix/pthreadimpl.h +++ b/cpukit/posix/include/rtems/posix/pthreadimpl.h @@ -44,7 +44,7 @@ extern "C" { * The following defines the information control block used to manage * this class of objects. */ -POSIX_EXTERN Objects_Information _POSIX_Threads_Information; +POSIX_EXTERN Thread_Information _POSIX_Threads_Information; /** * This variable contains the default POSIX Thread attributes. @@ -171,7 +171,7 @@ RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Threads_Allocate(void) _Thread_Kill_zombies(); return (Thread_Control *) - _Objects_Allocate_unprotected( &_POSIX_Threads_Information ); + _Objects_Allocate_unprotected( &_POSIX_Threads_Information.Objects ); } /* @@ -200,7 +200,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Free ( Thread_Control *the_pthread ) { - _Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object ); + _Objects_Free( &_POSIX_Threads_Information.Objects, &the_pthread->Object ); } /* diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c index d08e68684b..a90f4b1221 100644 --- a/cpukit/posix/src/killinfo.c +++ b/cpukit/posix/src/killinfo.c @@ -70,11 +70,11 @@ int killinfo( Thread_Control *the_thread; Thread_Control *interested; Priority_Control interested_priority; - Chain_Control *the_chain; Chain_Node *the_node; siginfo_t siginfo_struct; siginfo_t *siginfo; POSIX_signals_Siginfo_node *psiginfo; + Thread_queue_Heads *heads; /* * Only supported for the "calling process" (i.e. this node). @@ -140,32 +140,35 @@ int killinfo( /* XXX violation of visibility -- need to define thread queue support */ - the_chain = &_POSIX_signals_Wait_queue.Queue.Heads.Fifo; + heads = _POSIX_signals_Wait_queue.Queue.heads; + if ( heads != NULL ) { + Chain_Control *the_chain = &heads->Heads.Fifo; - for ( the_node = _Chain_First( the_chain ); - !_Chain_Is_tail( the_chain, the_node ) ; - the_node = the_node->next ) { + for ( the_node = _Chain_First( the_chain ); + !_Chain_Is_tail( the_chain, the_node ) ; + the_node = the_node->next ) { - the_thread = THREAD_CHAIN_NODE_TO_THREAD( the_node ); - api = the_thread->API_Extensions[ THREAD_API_POSIX ]; + the_thread = THREAD_CHAIN_NODE_TO_THREAD( the_node ); + api = the_thread->API_Extensions[ THREAD_API_POSIX ]; - #if defined(DEBUG_SIGNAL_PROCESSING) - printk( "Waiting Thread=%p option=0x%08x mask=0x%08x blocked=0x%08x\n", - the_thread, the_thread->Wait.option, mask, api->signals_blocked); - #endif + #if defined(DEBUG_SIGNAL_PROCESSING) + printk( "Waiting Thread=%p option=0x%08x mask=0x%08x blocked=0x%08x\n", + the_thread, the_thread->Wait.option, mask, api->signals_blocked); + #endif - /* - * Is this thread is actually blocked waiting for the signal? - */ - if (the_thread->Wait.option & mask) - goto process_it; + /* + * Is this thread is actually blocked waiting for the signal? + */ + if (the_thread->Wait.option & mask) + goto process_it; - /* - * Is this thread is blocked waiting for another signal but has - * not blocked this one? - */ - if (~api->signals_blocked & mask) - goto process_it; + /* + * Is this thread is blocked waiting for another signal but has + * not blocked this one? + */ + if (~api->signals_blocked & mask) + goto process_it; + } } /* diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index 02d86b5536..dc31449d82 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -370,19 +370,17 @@ void _POSIX_Threads_Manager_initialization(void) CPU_COPY( attr->affinityset, affinity->set ); #endif - _Objects_Initialize_information( + _Thread_Initialize_information( &_POSIX_Threads_Information, /* object information table */ OBJECTS_POSIX_API, /* object API */ OBJECTS_POSIX_THREADS, /* object class */ Configuration_POSIX_API.maximum_threads, /* maximum objects of this class */ - _Thread_Control_size, /* size of this object's control block */ true, /* true if names for this object are strings */ _POSIX_PATH_MAX /* 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 ); |