source: rtems/cpukit/posix/src/pthreadexit.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 290d2b79, checked in by Joel Sherrill <joel.sherrill@…>, on 06/29/09 at 23:19:28

2009-06-29 Joel Sherrill <joel.sherrill@…>

  • posix/src/killinfo.c, posix/src/mutexinit.c, posix/src/psignal.c, posix/src/psignalchecksignal.c, posix/src/pthread.c, posix/src/pthreadexit.c, posix/src/pthreadinitthreads.c: Remove includes of <assert.h> where possible. Make other uses conditional on ifdef RTEMS_DEBUG.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  16.1.5.1 Thread Termination, p1003.1c/Draft 10, p. 150
3 *
4 *  NOTE: Key destructors are executed in the POSIX api delete extension.
5 *
6 *  COPYRIGHT (c) 1989-2008.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <pthread.h>
21#include <errno.h>
22
23#include <rtems/system.h>
24#include <rtems/score/apimutex.h>
25#include <rtems/score/thread.h>
26#include <rtems/posix/pthread.h>
27
28void _POSIX_Thread_Exit(
29  Thread_Control *the_thread,
30  void           *value_ptr
31)
32{
33  Objects_Information     *the_information;
34
35  the_information = _Objects_Get_information_id( the_thread->Object.id );
36
37  /*
38   * The_information has to be non-NULL.  Otherwise, we couldn't be
39   * running in a thread of this API and class.
40   *
41   * NOTE: Lock and unlock in different order so we do not throw a
42   *       fatal error when locking the allocator mutex.  And after
43   *       we unlock, we want to defer the context switch until we
44   *       are ready to be switched out.  Otherwise, an ISR could
45   *       occur and preempt us out while we still hold the
46   *       allocator mutex.
47   */
48 
49  _RTEMS_Lock_allocator();
50    _Thread_Disable_dispatch();
51
52      the_thread->Wait.return_argument = value_ptr;
53
54      _Thread_Close( the_information, the_thread );
55
56      _POSIX_Threads_Free( the_thread );
57
58    _RTEMS_Unlock_allocator();
59  _Thread_Enable_dispatch();
60}
61
62void pthread_exit(
63  void  *value_ptr
64)
65{
66  _POSIX_Thread_Exit( _Thread_Executing, value_ptr );
67}
Note: See TracBrowser for help on using the repository browser.