summaryrefslogtreecommitdiffstats
path: root/c/src/exec/posix/src/pthread.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-03 22:08:18 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-06-03 22:08:18 +0000
commit8f857992265a97869cb569f0ae1995ea7407a51a (patch)
tree3f0ae9ec0627f9423d603841a01404900b5952dd /c/src/exec/posix/src/pthread.c
parentadded thread queue for list of threads waiting to join. (diff)
downloadrtems-8f857992265a97869cb569f0ae1995ea7407a51a.tar.bz2
added thread queue for list of threads waiting to join.
thread is added to join list in pthread_join. all threads waiting on the join list are flushed when the thread exits.
Diffstat (limited to 'c/src/exec/posix/src/pthread.c')
-rw-r--r--c/src/exec/posix/src/pthread.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/c/src/exec/posix/src/pthread.c b/c/src/exec/posix/src/pthread.c
index 23a9e606e0..3ce80144d7 100644
--- a/c/src/exec/posix/src/pthread.c
+++ b/c/src/exec/posix/src/pthread.c
@@ -694,6 +694,15 @@ int pthread_create(
api->Attributes = *attrp;
api->detachstate = attr->detachstate;
+ _Thread_queue_Initialize(
+ &api->Join_List,
+ OBJECTS_NO_CLASS, /* only used for proxy operations */
+ THREAD_QUEUE_DISCIPLINE_FIFO,
+ 0, /* XXX join blocking state */
+ NULL, /* no extract proxy handler */
+ 0
+ );
+
status = _Thread_Start(
the_thread,
THREAD_START_POINTER,
@@ -750,10 +759,17 @@ int pthread_join(
if ( api->detachstate == PTHREAD_CREATE_DETACHED )
return EINVAL;
- /* XXX do something useful here */
+ /*
+ * Put ourself on the threads join list
+ */
- return POSIX_NOT_IMPLEMENTED();
- break;
+ /* XXX is this right? */
+
+ _Thread_Executing->Wait.return_argument = (unsigned32 *) value_ptr;
+
+ _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
+
+ return 0;
}
return POSIX_BOTTOM_REACHED();
@@ -796,21 +812,28 @@ void pthread_exit(
void *value_ptr
)
{
+ register Thread_Control *executing;
register Thread_Control *the_thread;
+ POSIX_API_Control *api;
- the_thread = _Thread_Executing;
+ executing = _Thread_Executing;
_Thread_Disable_dispatch();
+ _Thread_Close( &_POSIX_Threads_Information, executing );
+
/*
- * XXX Will need to deal with join/detach
+ * Wakeup all the tasks which joined with this one
*/
+ api = executing->API_Extensions[ THREAD_API_POSIX ];
+
+ while ( (the_thread = _Thread_queue_Dequeue( &api->Join_List )) )
+ *(void **)the_thread->Wait.return_argument = value_ptr;
+
/* XXX run _POSIX_Keys_Run_destructors here? */
- _Thread_Close( &_POSIX_Threads_Information, the_thread );
-
- _POSIX_Threads_Free( the_thread );
+ _POSIX_Threads_Free( executing );
_Thread_Enable_dispatch();
}
@@ -863,8 +886,9 @@ int pthread_equal(
case OBJECTS_REMOTE:
return 0;
case OBJECTS_LOCAL:
- return _Objects_Are_ids_equal( t1, t2 );
+ break;
}
+ return _Objects_Are_ids_equal( t1, t2 );
}
/*PAGE