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
|
||||
*/
|
||||
|
||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
||||
STATIC INLINE Thread_Control *_POSIX_Threads_Allocate( void )
|
||||
{
|
||||
return (POSIX_Threads_Control *)
|
||||
_Objects_Allocate( &_POSIX_Threads_Information );
|
||||
return (Thread_Control *) _Objects_Allocate( &_POSIX_Threads_Information );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -34,7 +33,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
||||
*/
|
||||
|
||||
STATIC INLINE void _POSIX_Threads_Free (
|
||||
POSIX_Threads_Control *the_pthread
|
||||
Thread_Control *the_pthread
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
||||
@@ -45,13 +44,13 @@ STATIC INLINE void _POSIX_Threads_Free (
|
||||
* _POSIX_Threads_Get
|
||||
*/
|
||||
|
||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
||||
Objects_Id *id,
|
||||
STATIC INLINE Thread_Control *_POSIX_Threads_Get (
|
||||
pthread_t id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Threads_Control *)
|
||||
_Objects_Get( &_POSIX_Threads_Information, *id, location );
|
||||
return (Thread_Control *)
|
||||
_Objects_Get( &_POSIX_Threads_Information, (Objects_Id)id, location );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -60,7 +59,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
||||
*/
|
||||
|
||||
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
||||
POSIX_Threads_Control *the_pthread
|
||||
Thread_Control *the_pthread
|
||||
)
|
||||
{
|
||||
return !the_pthread;
|
||||
|
||||
@@ -22,10 +22,9 @@
|
||||
* _POSIX_Threads_Allocate
|
||||
*/
|
||||
|
||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
||||
STATIC INLINE Thread_Control *_POSIX_Threads_Allocate( void )
|
||||
{
|
||||
return (POSIX_Threads_Control *)
|
||||
_Objects_Allocate( &_POSIX_Threads_Information );
|
||||
return (Thread_Control *) _Objects_Allocate( &_POSIX_Threads_Information );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -34,7 +33,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Allocate( void )
|
||||
*/
|
||||
|
||||
STATIC INLINE void _POSIX_Threads_Free (
|
||||
POSIX_Threads_Control *the_pthread
|
||||
Thread_Control *the_pthread
|
||||
)
|
||||
{
|
||||
_Objects_Free( &_POSIX_Threads_Information, &the_pthread->Object );
|
||||
@@ -45,13 +44,13 @@ STATIC INLINE void _POSIX_Threads_Free (
|
||||
* _POSIX_Threads_Get
|
||||
*/
|
||||
|
||||
STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
||||
Objects_Id *id,
|
||||
STATIC INLINE Thread_Control *_POSIX_Threads_Get (
|
||||
pthread_t id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
return (POSIX_Threads_Control *)
|
||||
_Objects_Get( &_POSIX_Threads_Information, *id, location );
|
||||
return (Thread_Control *)
|
||||
_Objects_Get( &_POSIX_Threads_Information, (Objects_Id)id, location );
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -60,7 +59,7 @@ STATIC INLINE POSIX_Threads_Control *_POSIX_Threads_Get (
|
||||
*/
|
||||
|
||||
STATIC INLINE boolean _POSIX_Threads_Is_null (
|
||||
POSIX_Threads_Control *the_pthread
|
||||
Thread_Control *the_pthread
|
||||
)
|
||||
{
|
||||
return !the_pthread;
|
||||
|
||||
@@ -178,7 +178,7 @@ void _POSIX_Threads_Manager_initialization(
|
||||
OBJECTS_POSIX_THREADS,
|
||||
FALSE, /* does not support global */
|
||||
maximum_pthreads,
|
||||
sizeof( POSIX_Threads_Control ),
|
||||
sizeof( Thread_Control ),
|
||||
TRUE,
|
||||
5, /* length is arbitrary for now */
|
||||
TRUE /* this class is threads */
|
||||
@@ -586,6 +586,7 @@ int pthread_create(
|
||||
boolean status;
|
||||
Thread_Control *the_thread;
|
||||
char *default_name = "psx";
|
||||
POSIX_API_Control *api;
|
||||
|
||||
attrp = (attr) ? attr : &_POSIX_Threads_Default_attributes;
|
||||
|
||||
@@ -683,6 +684,16 @@ int pthread_create(
|
||||
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(
|
||||
the_thread,
|
||||
THREAD_START_POINTER,
|
||||
@@ -724,7 +735,28 @@ int pthread_join(
|
||||
void **value_ptr
|
||||
)
|
||||
{
|
||||
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 ];
|
||||
|
||||
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
|
||||
return EINVAL;
|
||||
|
||||
/* XXX do something useful here */
|
||||
|
||||
return POSIX_NOT_IMPLEMENTED();
|
||||
break;
|
||||
}
|
||||
|
||||
return POSIX_BOTTOM_REACHED();
|
||||
}
|
||||
|
||||
/*PAGE
|
||||
@@ -736,7 +768,23 @@ int pthread_detach(
|
||||
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
|
||||
@@ -787,11 +835,36 @@ int pthread_equal(
|
||||
pthread_t t2
|
||||
)
|
||||
{
|
||||
#ifdef RTEMS_DEBUG
|
||||
Objects_Locations location;
|
||||
|
||||
/* XXX may want to do a "get" to make sure both are valid. */
|
||||
/* 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
|
||||
|
||||
@@ -188,7 +188,7 @@ int clock_gettime(
|
||||
|
||||
#ifdef _POSIX_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();
|
||||
break;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user