summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadexit.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-05-22 20:38:03 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-05-22 20:38:03 +0000
commit345fc11da9dcad5faa23f9888c8f3a0260e8ad45 (patch)
tree561c791f8d6342c00391dea6c1dd47f08ac82612 /cpukit/posix/src/pthreadexit.c
parent2008-05-22 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-345fc11da9dcad5faa23f9888c8f3a0260e8ad45.tar.bz2
2008-05-22 Joel Sherrill <joel.sherrill@oarcorp.com>
* itron/include/rtems/itron/task.h, itron/src/del_tsk.c, itron/src/exd_tsk.c, itron/src/task.c, posix/include/rtems/posix/threadsup.h, posix/src/cancel.c, posix/src/cancelrun.c, posix/src/pthread.c, posix/src/pthreadexit.c, posix/src/setcancelstate.c, posix/src/setcanceltype.c, posix/src/testcancel.c, rtems/src/taskdelete.c, score/inline/rtems/score/object.inl, score/src/objectclose.c, score/src/threadclose.c: Make all task delete/exit/cancel routines follow the same critical section pattern. Also ensure that POSIX cancelation routines are run at thread exit.
Diffstat (limited to 'cpukit/posix/src/pthreadexit.c')
-rw-r--r--cpukit/posix/src/pthreadexit.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c
index a8781f5c58..f85e736daa 100644
--- a/cpukit/posix/src/pthreadexit.c
+++ b/cpukit/posix/src/pthreadexit.c
@@ -22,29 +22,47 @@
#include <assert.h>
#include <rtems/system.h>
+#include <rtems/score/apimutex.h>
#include <rtems/score/thread.h>
#include <rtems/posix/pthread.h>
-void pthread_exit(
- void *value_ptr
+void _POSIX_Thread_Exit(
+ Thread_Control *the_thread,
+ void *value_ptr
)
{
Objects_Information *the_information;
- the_information = _Objects_Get_information_id( _Thread_Executing->Object.id );
+ the_information = _Objects_Get_information_id( the_thread->Object.id );
/*
- * the_information has to be non-NULL. Otherwise, we couldn't be
+ * The_information has to be non-NULL. Otherwise, we couldn't be
* running in a thread of this API and class.
+ *
+ * NOTE: Lock and unlock in different order so we do not throw a
+ * fatal error when locking the allocator mutex. And after
+ * we unlock, we want to defer the context switch until we
+ * are ready to be switched out. Otherwise, an ISR could
+ * occur and preempt us out while we still hold the
+ * allocator mutex.
*/
- _Thread_Disable_dispatch();
+ _RTEMS_Lock_allocator();
+ _Thread_Disable_dispatch();
- _Thread_Executing->Wait.return_argument = value_ptr;
+ the_thread->Wait.return_argument = value_ptr;
- _Thread_Close( the_information, _Thread_Executing );
+ _Thread_Close( the_information, the_thread );
- _POSIX_Threads_Free( _Thread_Executing );
+ _POSIX_Threads_Free( the_thread );
+ _RTEMS_Unlock_allocator();
_Thread_Enable_dispatch();
}
+
+void pthread_exit(
+ void *value_ptr
+)
+{
+ _POSIX_Thread_Exit( _Thread_Executing, value_ptr );
+}