From 69aa33490b1cd357519ab70b15ad150e11bb752e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 8 Apr 2014 09:42:29 +0200 Subject: score: Simplify thread control initialization The thread control block contains fields that point to application configuration dependent memory areas, like the scheduler information, the API control blocks, the user extension context table, the RTEMS notepads and the Newlib re-entrancy support. Account for these areas in the configuration and avoid extra workspace allocations for these areas. This helps also to avoid heap fragementation and reduces the per thread memory due to a reduced heap allocation overhead. --- cpukit/posix/src/pthread.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'cpukit/posix') diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c index 6f79658677..ab197f3a51 100644 --- a/cpukit/posix/src/pthread.c +++ b/cpukit/posix/src/pthread.c @@ -190,12 +190,7 @@ static bool _POSIX_Threads_Create_extension( POSIX_API_Control *api; POSIX_API_Control *executing_api; - api = _Workspace_Allocate( sizeof( POSIX_API_Control ) ); - - if ( !api ) - return false; - - created->API_Extensions[ THREAD_API_POSIX ] = api; + api = created->API_Extensions[ THREAD_API_POSIX ]; /* XXX check all fields are touched */ _POSIX_Threads_Initialize_attributes( &api->Attributes ); @@ -266,19 +261,6 @@ static void _POSIX_Threads_Restart_extension( _POSIX_Threads_cancel_run( restarted ); } -/* - * _POSIX_Threads_Delete_extension - * - * This method is invoked for each thread deleted. - */ -static void _POSIX_Threads_Delete_extension( - Thread_Control *executing __attribute__((unused)), - Thread_Control *deleted -) -{ - _Workspace_Free( deleted->API_Extensions[ THREAD_API_POSIX ] ); -} - static void _POSIX_Threads_Terminate_extension( Thread_Control *executing ) @@ -355,7 +337,7 @@ User_extensions_Control _POSIX_Threads_User_extensions = { { _POSIX_Threads_Create_extension, /* create */ NULL, /* start */ _POSIX_Threads_Restart_extension, /* restart */ - _POSIX_Threads_Delete_extension, /* delete */ + NULL, /* delete */ NULL, /* switch */ NULL, /* begin */ _POSIX_Threads_Exitted_extension, /* exitted */ @@ -392,8 +374,7 @@ void _POSIX_Threads_Manager_initialization(void) OBJECTS_POSIX_THREADS, /* object class */ Configuration_POSIX_API.maximum_threads, /* maximum objects of this class */ - sizeof( Thread_Control ), - /* size of this object's control block */ + _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) -- cgit v1.2.3