added initial set of api extension callouts

This commit is contained in:
Joel Sherrill
1996-05-28 19:28:32 +00:00
parent 2b4683a156
commit 5a18e047ac
8 changed files with 316 additions and 10 deletions

View File

@@ -21,6 +21,9 @@
extern "C" {
#endif
#include <rtems/posix/config.h>
#include <rtems/posix/threadsup.h>
/*
* 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
);
/*

View File

@@ -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 */

View File

@@ -21,6 +21,9 @@
extern "C" {
#endif
#include <rtems/posix/config.h>
#include <rtems/posix/threadsup.h>
/*
* 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
);
/*

View File

@@ -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 */

View File

@@ -7,9 +7,13 @@
#include <limits.h>
#include <rtems/system.h>
#include <rtems/score/apiext.h>
#include <rtems/score/stack.h>
#include <rtems/score/thread.h>
#include <rtems/score/userext.h>
#include <rtems/score/wkspace.h>
#include <rtems/posix/pthread.h>
#include <rtems/posix/config.h>
/*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

View File

@@ -21,6 +21,9 @@
extern "C" {
#endif
#include <rtems/posix/config.h>
#include <rtems/posix/threadsup.h>
/*
* 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
);
/*

View File

@@ -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 */

View File

@@ -7,9 +7,13 @@
#include <limits.h>
#include <rtems/system.h>
#include <rtems/score/apiext.h>
#include <rtems/score/stack.h>
#include <rtems/score/thread.h>
#include <rtems/score/userext.h>
#include <rtems/score/wkspace.h>
#include <rtems/posix/pthread.h>
#include <rtems/posix/config.h>
/*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