From 5a18e047aca9569bef0978a515c23f64ff597b57 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 28 May 1996 19:28:32 +0000 Subject: added initial set of api extension callouts --- c/src/exec/posix/headers/pthread.h | 16 ++- c/src/exec/posix/headers/threadsup.h | 2 +- c/src/exec/posix/include/rtems/posix/pthread.h | 16 ++- c/src/exec/posix/include/rtems/posix/threadsup.h | 2 +- c/src/exec/posix/src/pthread.c | 136 ++++++++++++++++++++++- 5 files changed, 166 insertions(+), 6 deletions(-) (limited to 'c') diff --git a/c/src/exec/posix/headers/pthread.h b/c/src/exec/posix/headers/pthread.h index 538e737268..1ec9d9f193 100644 --- a/c/src/exec/posix/headers/pthread.h +++ b/c/src/exec/posix/headers/pthread.h @@ -21,6 +21,9 @@ extern "C" { #endif +#include +#include + /* * Data Structure used to manage a POSIX thread */ @@ -33,6 +36,15 @@ typedef Thread_Control POSIX_Threads_Control; */ EXTERN Objects_Information _POSIX_Threads_Information; + +/* + * These are used to manage the user initialization tasks. + */ + +EXTERN posix_initialization_tasks_table + *_POSIX_Threads_User_initialization_tasks; +EXTERN unsigned32 _POSIX_Threads_Number_of_initialization_tasks; + /* * _POSIX_Threads_Manager_initialization @@ -43,7 +55,9 @@ EXTERN Objects_Information _POSIX_Threads_Information; */ void _POSIX_Threads_Manager_initialization( - unsigned32 maximum_pthreads + unsigned32 maximum_pthreads, + unsigned32 number_of_initialization_tasks, + posix_initialization_tasks_table *user_tasks ); /* diff --git a/c/src/exec/posix/headers/threadsup.h b/c/src/exec/posix/headers/threadsup.h index e0cf294494..e614df12ef 100644 --- a/c/src/exec/posix/headers/threadsup.h +++ b/c/src/exec/posix/headers/threadsup.h @@ -25,7 +25,7 @@ typedef struct { int cancelation_requested; Chain_Control Cancellation_Handlers; -} POSIX_API_Thread_Support_Control; +} POSIX_API_Control; #endif /* end of include file */ diff --git a/c/src/exec/posix/include/rtems/posix/pthread.h b/c/src/exec/posix/include/rtems/posix/pthread.h index 538e737268..1ec9d9f193 100644 --- a/c/src/exec/posix/include/rtems/posix/pthread.h +++ b/c/src/exec/posix/include/rtems/posix/pthread.h @@ -21,6 +21,9 @@ extern "C" { #endif +#include +#include + /* * Data Structure used to manage a POSIX thread */ @@ -33,6 +36,15 @@ typedef Thread_Control POSIX_Threads_Control; */ EXTERN Objects_Information _POSIX_Threads_Information; + +/* + * These are used to manage the user initialization tasks. + */ + +EXTERN posix_initialization_tasks_table + *_POSIX_Threads_User_initialization_tasks; +EXTERN unsigned32 _POSIX_Threads_Number_of_initialization_tasks; + /* * _POSIX_Threads_Manager_initialization @@ -43,7 +55,9 @@ EXTERN Objects_Information _POSIX_Threads_Information; */ void _POSIX_Threads_Manager_initialization( - unsigned32 maximum_pthreads + unsigned32 maximum_pthreads, + unsigned32 number_of_initialization_tasks, + posix_initialization_tasks_table *user_tasks ); /* diff --git a/c/src/exec/posix/include/rtems/posix/threadsup.h b/c/src/exec/posix/include/rtems/posix/threadsup.h index e0cf294494..e614df12ef 100644 --- a/c/src/exec/posix/include/rtems/posix/threadsup.h +++ b/c/src/exec/posix/include/rtems/posix/threadsup.h @@ -25,7 +25,7 @@ typedef struct { int cancelation_requested; Chain_Control Cancellation_Handlers; -} POSIX_API_Thread_Support_Control; +} POSIX_API_Control; #endif /* end of include file */ diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c index 0ed00ea568..3a94245c98 100644 --- a/c/src/exec/posix/src/pthread.c +++ b/c/src/exec/posix/src/pthread.c @@ -7,9 +7,13 @@ #include #include +#include #include #include +#include +#include #include +#include /*PAGE * @@ -33,6 +37,100 @@ const pthread_attr_t _POSIX_Threads_Default_attributes = { 1 /* cputime_clock_allowed */ }; +/*PAGE + * + * _POSIX_Threads_Create_extension + * + * XXX + */ + +boolean _POSIX_Threads_Create_extension( + Thread_Control *executing, + Thread_Control *created +) +{ + POSIX_API_Control *api; + + api = _Workspace_Allocate( sizeof( POSIX_API_Control ) ); + + if ( !api ) + return FALSE; + + created->API_Extensions[ THREAD_API_POSIX ] = api; + + /* XXX something should go here */ + + return TRUE; +} + +/*PAGE + * + * _POSIX_Threads_Delete_extension + * + * XXX + */ + +User_extensions_routine _POSIX_Threads_Delete_extension( + Thread_Control *executing, + Thread_Control *deleted +) +{ + (void) _Workspace_Free( deleted->API_Extensions[ THREAD_API_POSIX ] ); + + deleted->API_Extensions[ THREAD_API_POSIX ] = NULL; +} + +/*PAGE + * + * _POSIX_Threads_Initialize_user_tasks + * + * This routine creates and starts all configured user + * initialzation threads. + * + * Input parameters: NONE + * + * Output parameters: NONE + */ + +void _POSIX_Threads_Initialize_user_tasks( void ) +{ + unsigned32 index; + unsigned32 maximum; + posix_initialization_tasks_table *user_tasks; + + /* + * NOTE: This is slightly different from the Ada implementation. + */ + + user_tasks = _POSIX_Threads_User_initialization_tasks; + maximum = _POSIX_Threads_Number_of_initialization_tasks; + + for ( index=0 ; index < maximum ; index++ ) { + ; + } +} + +API_extensions_Control _POSIX_Threads_API_extensions = { + { NULL, NULL }, + NULL, /* predriver */ + _POSIX_Threads_Initialize_user_tasks, /* postdriver */ + NULL, /* post switch */ +}; + +User_extensions_Control _POSIX_Threads_User_extensions = { + { NULL, NULL }, + { _POSIX_Threads_Create_extension, /* create */ + NULL, /* start */ + NULL, /* restart */ + _POSIX_Threads_Delete_extension, /* delete */ + NULL, /* switch */ + NULL, /* begin */ + NULL, /* exitted */ + NULL /* fatal */ + } +}; + + /*PAGE * * _POSIX_Threads_Manager_initialization @@ -46,9 +144,19 @@ const pthread_attr_t _POSIX_Threads_Default_attributes = { */ void _POSIX_Threads_Manager_initialization( - unsigned32 maximum_pthreads + unsigned32 maximum_pthreads, + unsigned32 number_of_initialization_tasks, + posix_initialization_tasks_table *user_tasks + ) { + _POSIX_Threads_Number_of_initialization_tasks = + number_of_initialization_tasks; + _POSIX_Threads_User_initialization_tasks = user_tasks; + + if ( user_tasks == NULL || number_of_initialization_tasks == 0 ) + _Internal_error_Occurred( INTERNAL_ERROR_POSIX_API, TRUE, EINVAL ); + _Objects_Initialize_information( &_POSIX_Threads_Information, OBJECTS_POSIX_THREADS, @@ -59,6 +167,8 @@ void _POSIX_Threads_Manager_initialization( _POSIX_PATH_MAX, TRUE ); + + /* XXX add api extensions */ } /*PAGE @@ -402,7 +512,29 @@ int pthread_create( void *arg ) { - return POSIX_NOT_IMPLEMENTED(); + const pthread_attr_t *local_attr; + + local_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes; + + if ( !local_attr->is_initialized ) + return EINVAL; + + /* + * Core Thread Initialize insures we get the minimum amount of + * stack space. + */ + +#if 0 + int contentionscope; + int inheritsched; + int schedpolicy; + struct sched_param schedparam; + +#if defined(_POSIX_THREAD_CPUTIME) + int cputime_clock_allowed; /* see time.h */ +#endif + int detachstate; +#endif } /*PAGE -- cgit v1.2.3