added pthread_exit

first posix thread ran
This commit is contained in:
Joel Sherrill
1996-05-29 20:55:05 +00:00
parent 5e0efa2b3a
commit cfcfdf0585
2 changed files with 90 additions and 16 deletions

View File

@@ -538,16 +538,16 @@ int pthread_create(
void *arg void *arg
) )
{ {
const pthread_attr_t *local_attr; const pthread_attr_t *attrp;
Priority_Control core_priority; Priority_Control core_priority;
boolean is_fp; boolean is_fp;
boolean status; boolean status;
Thread_Control *the_thread; Thread_Control *the_thread;
char *default_name = "psx"; char *default_name = "psx";
local_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes; attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
if ( !local_attr->is_initialized ) if ( !attrp->is_initialized )
return EINVAL; return EINVAL;
/* /*
@@ -571,10 +571,10 @@ int pthread_create(
* Validate the RTEMS API priority and convert it to the core priority range. * Validate the RTEMS API priority and convert it to the core priority range.
*/ */
if ( !_POSIX_Priority_Is_valid( attr->schedparam.sched_priority ) ) if ( !_POSIX_Priority_Is_valid( attrp->schedparam.sched_priority ) )
return EINVAL; return EINVAL;
core_priority = _POSIX_Priority_To_core( attr->schedparam.sched_priority ); core_priority = _POSIX_Priority_To_core( attrp->schedparam.sched_priority );
/* /*
* Currently all POSIX threads are floating point. * Currently all POSIX threads are floating point.
@@ -608,8 +608,8 @@ int pthread_create(
status = _Thread_Initialize( status = _Thread_Initialize(
&_POSIX_Threads_Information, &_POSIX_Threads_Information,
the_thread, the_thread,
attr->stackaddr, attrp->stackaddr,
attr->stacksize, attrp->stacksize,
is_fp, is_fp,
core_priority, core_priority,
TRUE, /* preemptible */ TRUE, /* preemptible */
@@ -624,6 +624,29 @@ int pthread_create(
return EINVAL; return EINVAL;
} }
status = _Thread_Start(
the_thread,
THREAD_START_POINTER,
start_routine,
arg,
0 /* unused */
);
/*
* _Thread_Start only fails if the thread was in the incorrect state
*/
if ( !status ) {
_POSIX_Threads_Free( the_thread );
_Thread_Enable_dispatch();
return EINVAL;
}
/*
* Return the id and indicate we successfully created the thread
*/
*thread = the_thread->Object.id; *thread = the_thread->Object.id;
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
@@ -666,7 +689,21 @@ void pthread_exit(
void *value_ptr void *value_ptr
) )
{ {
POSIX_NOT_IMPLEMENTED(); register Thread_Control *the_thread;
the_thread = _Thread_Executing;
_Thread_Disable_dispatch();
/*
* XXX Will need to deal with join/detach
*/
_Thread_Close( &_POSIX_Threads_Information, the_thread );
_POSIX_Threads_Free( the_thread );
_Thread_Enable_dispatch();
} }
/*PAGE /*PAGE

View File

@@ -538,16 +538,16 @@ int pthread_create(
void *arg void *arg
) )
{ {
const pthread_attr_t *local_attr; const pthread_attr_t *attrp;
Priority_Control core_priority; Priority_Control core_priority;
boolean is_fp; boolean is_fp;
boolean status; boolean status;
Thread_Control *the_thread; Thread_Control *the_thread;
char *default_name = "psx"; char *default_name = "psx";
local_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes; attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
if ( !local_attr->is_initialized ) if ( !attrp->is_initialized )
return EINVAL; return EINVAL;
/* /*
@@ -571,10 +571,10 @@ int pthread_create(
* Validate the RTEMS API priority and convert it to the core priority range. * Validate the RTEMS API priority and convert it to the core priority range.
*/ */
if ( !_POSIX_Priority_Is_valid( attr->schedparam.sched_priority ) ) if ( !_POSIX_Priority_Is_valid( attrp->schedparam.sched_priority ) )
return EINVAL; return EINVAL;
core_priority = _POSIX_Priority_To_core( attr->schedparam.sched_priority ); core_priority = _POSIX_Priority_To_core( attrp->schedparam.sched_priority );
/* /*
* Currently all POSIX threads are floating point. * Currently all POSIX threads are floating point.
@@ -608,8 +608,8 @@ int pthread_create(
status = _Thread_Initialize( status = _Thread_Initialize(
&_POSIX_Threads_Information, &_POSIX_Threads_Information,
the_thread, the_thread,
attr->stackaddr, attrp->stackaddr,
attr->stacksize, attrp->stacksize,
is_fp, is_fp,
core_priority, core_priority,
TRUE, /* preemptible */ TRUE, /* preemptible */
@@ -624,6 +624,29 @@ int pthread_create(
return EINVAL; return EINVAL;
} }
status = _Thread_Start(
the_thread,
THREAD_START_POINTER,
start_routine,
arg,
0 /* unused */
);
/*
* _Thread_Start only fails if the thread was in the incorrect state
*/
if ( !status ) {
_POSIX_Threads_Free( the_thread );
_Thread_Enable_dispatch();
return EINVAL;
}
/*
* Return the id and indicate we successfully created the thread
*/
*thread = the_thread->Object.id; *thread = the_thread->Object.id;
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
@@ -666,7 +689,21 @@ void pthread_exit(
void *value_ptr void *value_ptr
) )
{ {
POSIX_NOT_IMPLEMENTED(); register Thread_Control *the_thread;
the_thread = _Thread_Executing;
_Thread_Disable_dispatch();
/*
* XXX Will need to deal with join/detach
*/
_Thread_Close( &_POSIX_Threads_Information, the_thread );
_POSIX_Threads_Free( the_thread );
_Thread_Enable_dispatch();
} }
/*PAGE /*PAGE