forked from Imagelibrary/rtems
deleted POSIX threads typedef masking Thread_Control
added initial version of pthread_detach and pthread_join
This commit is contained in:
@@ -22,10 +22,9 @@
|
|||||||
* _POSIX_Threads_Allocate
|
* _POSIX_Threads_Allocate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
STATIC INLINE Thread_Control *_POSIX_Threads_Allocate( void )
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *) _Objects_Allocate( &_POSIX_Threads_Information );
|
||||||
_Objects_Allocate( &_POSIX_Threads_Information );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -34,7 +33,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE void _POSIX_Threads_Free (
|
STATIC INLINE void _POSIX_Threads_Free (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
||||||
@@ -45,13 +44,13 @@ STATIC INLINE void _POSIX_Threads_Free (
|
|||||||
* _POSIX_Threads_Get
|
* _POSIX_Threads_Get
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
STATIC INLINE Thread_Control *_POSIX_Threads_Get (
|
||||||
Objects_Id *id,
|
pthread_t id,
|
||||||
Objects_Locations *location
|
Objects_Locations *location
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *)
|
||||||
_Objects_Get( &_POSIX_Threads_Information, *id, location );
|
_Objects_Get( &_POSIX_Threads_Information, (Objects_Id)id, location );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -60,7 +59,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return !the_pthread;
|
return !the_pthread;
|
||||||
|
|||||||
@@ -22,10 +22,9 @@
|
|||||||
* _POSIX_Threads_Allocate
|
* _POSIX_Threads_Allocate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
STATIC INLINE Thread_Control *_POSIX_Threads_Allocate( void )
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *) _Objects_Allocate( &_POSIX_Threads_Information );
|
||||||
_Objects_Allocate( &_POSIX_Threads_Information );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -34,7 +33,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE void _POSIX_Threads_Free (
|
STATIC INLINE void _POSIX_Threads_Free (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
||||||
@@ -45,13 +44,13 @@ STATIC INLINE void _POSIX_Threads_Free (
|
|||||||
* _POSIX_Threads_Get
|
* _POSIX_Threads_Get
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
STATIC INLINE Thread_Control *_POSIX_Threads_Get (
|
||||||
Objects_Id *id,
|
pthread_t id,
|
||||||
Objects_Locations *location
|
Objects_Locations *location
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *)
|
||||||
_Objects_Get( &_POSIX_Threads_Information, *id, location );
|
_Objects_Get( &_POSIX_Threads_Information, (Objects_Id)id, location );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -60,7 +59,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return !the_pthread;
|
return !the_pthread;
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ void _POSIX_Threads_Manager_initialization(
|
|||||||
OBJECTS_POSIX_THREADS,
|
OBJECTS_POSIX_THREADS,
|
||||||
FALSE, /* does not support global */
|
FALSE, /* does not support global */
|
||||||
maximum_pthreads,
|
maximum_pthreads,
|
||||||
sizeof( POSIX_Threads_Control ),
|
sizeof( Thread_Control ),
|
||||||
TRUE,
|
TRUE,
|
||||||
5, /* length is arbitrary for now */
|
5, /* length is arbitrary for now */
|
||||||
TRUE /* this class is threads */
|
TRUE /* this class is threads */
|
||||||
@@ -586,6 +586,7 @@ int pthread_create(
|
|||||||
boolean status;
|
boolean status;
|
||||||
Thread_Control *the_thread;
|
Thread_Control *the_thread;
|
||||||
char *default_name = "psx";
|
char *default_name = "psx";
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
|
||||||
attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
|
attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
|
||||||
|
|
||||||
@@ -683,6 +684,16 @@ int pthread_create(
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* finish initializing the per API structure
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
api->Attributes = *attrp;
|
||||||
|
api->detachstate = attr->detachstate;
|
||||||
|
|
||||||
status = _Thread_Start(
|
status = _Thread_Start(
|
||||||
the_thread,
|
the_thread,
|
||||||
THREAD_START_POINTER,
|
THREAD_START_POINTER,
|
||||||
@@ -724,7 +735,28 @@ int pthread_join(
|
|||||||
void **value_ptr
|
void **value_ptr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
register Thread_Control *the_thread;
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
/* XXX do something useful here */
|
||||||
|
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
return POSIX_NOT_IMPLEMENTED();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -736,7 +768,23 @@ int pthread_detach(
|
|||||||
pthread_t thread
|
pthread_t thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
register Thread_Control *the_thread;
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
api->detachstate = PTHREAD_CREATE_DETACHED;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -787,11 +835,36 @@ int pthread_equal(
|
|||||||
pthread_t t2
|
pthread_t t2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef RTEMS_DEBUG
|
Objects_Locations location;
|
||||||
|
|
||||||
/* XXX may want to do a "get" to make sure both are valid. */
|
/* XXX may want to do a "get" to make sure both are valid. */
|
||||||
/* XXX behavior is undefined if not valid pthread_t's */
|
/* XXX behavior is undefined if not valid pthread_t's */
|
||||||
#endif
|
|
||||||
return _Objects_Are_ids_equal( t1, t1 );
|
/*
|
||||||
|
* Validate the first id and return 0 if it is not valid
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void) _POSIX_Threads_Get( t1, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return 0;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validate the second id and return 0 if it is not valid
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void) _POSIX_Threads_Get( t2, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return 0;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
return _Objects_Are_ids_equal( t1, t2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ int clock_gettime(
|
|||||||
|
|
||||||
#ifdef _POSIX_CPUTIME
|
#ifdef _POSIX_CPUTIME
|
||||||
case CLOCK_PROCESS_CPUTIME:
|
case CLOCK_PROCESS_CPUTIME:
|
||||||
/* could base this on _Watchdog_Ticks_since_boot -- must make set work though*/
|
/* don't base this on _Watchdog_Ticks_since_boot--duration is too short*/
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
return POSIX_NOT_IMPLEMENTED();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,10 +22,9 @@
|
|||||||
* _POSIX_Threads_Allocate
|
* _POSIX_Threads_Allocate
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
STATIC INLINE Thread_Control *_POSIX_Threads_Allocate( void )
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *) _Objects_Allocate( &_POSIX_Threads_Information );
|
||||||
_Objects_Allocate( &_POSIX_Threads_Information );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -34,7 +33,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE void _POSIX_Threads_Free (
|
STATIC INLINE void _POSIX_Threads_Free (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
||||||
@@ -45,13 +44,13 @@ STATIC INLINE void _POSIX_Threads_Free (
|
|||||||
* _POSIX_Threads_Get
|
* _POSIX_Threads_Get
|
||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
STATIC INLINE Thread_Control *_POSIX_Threads_Get (
|
||||||
Objects_Id *id,
|
pthread_t id,
|
||||||
Objects_Locations *location
|
Objects_Locations *location
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return (POSIX_Threads_Control *)
|
return (Thread_Control *)
|
||||||
_Objects_Get( &_POSIX_Threads_Information, *id, location );
|
_Objects_Get( &_POSIX_Threads_Information, (Objects_Id)id, location );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -60,7 +59,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
||||||
POSIX_Threads_Control *the_pthread
|
Thread_Control *the_pthread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return !the_pthread;
|
return !the_pthread;
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ void _POSIX_Threads_Manager_initialization(
|
|||||||
OBJECTS_POSIX_THREADS,
|
OBJECTS_POSIX_THREADS,
|
||||||
FALSE, /* does not support global */
|
FALSE, /* does not support global */
|
||||||
maximum_pthreads,
|
maximum_pthreads,
|
||||||
sizeof( POSIX_Threads_Control ),
|
sizeof( Thread_Control ),
|
||||||
TRUE,
|
TRUE,
|
||||||
5, /* length is arbitrary for now */
|
5, /* length is arbitrary for now */
|
||||||
TRUE /* this class is threads */
|
TRUE /* this class is threads */
|
||||||
@@ -586,6 +586,7 @@ int pthread_create(
|
|||||||
boolean status;
|
boolean status;
|
||||||
Thread_Control *the_thread;
|
Thread_Control *the_thread;
|
||||||
char *default_name = "psx";
|
char *default_name = "psx";
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
|
||||||
attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
|
attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
|
||||||
|
|
||||||
@@ -683,6 +684,16 @@ int pthread_create(
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* finish initializing the per API structure
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
api->Attributes = *attrp;
|
||||||
|
api->detachstate = attr->detachstate;
|
||||||
|
|
||||||
status = _Thread_Start(
|
status = _Thread_Start(
|
||||||
the_thread,
|
the_thread,
|
||||||
THREAD_START_POINTER,
|
THREAD_START_POINTER,
|
||||||
@@ -724,7 +735,28 @@ int pthread_join(
|
|||||||
void **value_ptr
|
void **value_ptr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
register Thread_Control *the_thread;
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
|
||||||
|
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
/* XXX do something useful here */
|
||||||
|
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
return POSIX_NOT_IMPLEMENTED();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -736,7 +768,23 @@ int pthread_detach(
|
|||||||
pthread_t thread
|
pthread_t thread
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
register Thread_Control *the_thread;
|
||||||
|
POSIX_API_Control *api;
|
||||||
|
Objects_Locations location;
|
||||||
|
|
||||||
|
the_thread = _POSIX_Threads_Get( thread, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return ESRCH;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
|
||||||
|
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||||
|
api->detachstate = PTHREAD_CREATE_DETACHED;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return POSIX_BOTTOM_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
@@ -787,11 +835,36 @@ int pthread_equal(
|
|||||||
pthread_t t2
|
pthread_t t2
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef RTEMS_DEBUG
|
Objects_Locations location;
|
||||||
|
|
||||||
/* XXX may want to do a "get" to make sure both are valid. */
|
/* XXX may want to do a "get" to make sure both are valid. */
|
||||||
/* XXX behavior is undefined if not valid pthread_t's */
|
/* XXX behavior is undefined if not valid pthread_t's */
|
||||||
#endif
|
|
||||||
return _Objects_Are_ids_equal( t1, t1 );
|
/*
|
||||||
|
* Validate the first id and return 0 if it is not valid
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void) _POSIX_Threads_Get( t1, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return 0;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Validate the second id and return 0 if it is not valid
|
||||||
|
*/
|
||||||
|
|
||||||
|
(void) _POSIX_Threads_Get( t2, &location );
|
||||||
|
switch ( location ) {
|
||||||
|
case OBJECTS_ERROR:
|
||||||
|
case OBJECTS_REMOTE:
|
||||||
|
return 0;
|
||||||
|
case OBJECTS_LOCAL:
|
||||||
|
return _Objects_Are_ids_equal( t1, t2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*PAGE
|
/*PAGE
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ int clock_gettime(
|
|||||||
|
|
||||||
#ifdef _POSIX_CPUTIME
|
#ifdef _POSIX_CPUTIME
|
||||||
case CLOCK_PROCESS_CPUTIME:
|
case CLOCK_PROCESS_CPUTIME:
|
||||||
/* could base this on _Watchdog_Ticks_since_boot -- must make set work though*/
|
/* don't base this on _Watchdog_Ticks_since_boot--duration is too short*/
|
||||||
return POSIX_NOT_IMPLEMENTED();
|
return POSIX_NOT_IMPLEMENTED();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user