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

4.104.115
Last change on this file since 8f6b7b51 was 860c34e, checked in by Glenn Humphrey <glenn.humphrey@…>, on 11/30/07 at 20:34:13

2007-11-30 Glenn Humphrey <glenn.humphrey@…>

  • posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes.
  • posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files.
  • posix/src/mutexfromcorestatus.c: Removed.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <pthread.h>
19#include <errno.h>
20
21#include <rtems/system.h>
22#include <rtems/score/thread.h>
23#include <rtems/posix/pthread.h>
24
25int pthread_join(
26  pthread_t   thread,
27  void      **value_ptr
28)
29{
30  register Thread_Control *the_thread;
31  POSIX_API_Control       *api;
32  Objects_Locations        location;
33  void                    *return_pointer;
34
35  the_thread = _POSIX_Threads_Get( thread, &location );
36  switch ( location ) {
37
38    case OBJECTS_LOCAL:
39      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
40
41      if ( api->detachstate == PTHREAD_CREATE_DETACHED ) {
42        _Thread_Enable_dispatch();
43        return EINVAL;
44      }
45
46      if ( _Thread_Is_executing( the_thread ) ) {
47        _Thread_Enable_dispatch();
48        return EDEADLK;
49      }
50
51      /*
52       *  Put ourself on the threads join list
53       */
54
55      _Thread_Executing->Wait.return_argument = &return_pointer;
56
57      _Thread_queue_Enter_critical_section( &api->Join_List );
58
59      _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
60
61      _Thread_Enable_dispatch();
62
63      if ( value_ptr )
64        *value_ptr = return_pointer;
65      return 0;
66
67#if defined(RTEMS_MULTIPROCESSING)
68    case OBJECTS_REMOTE:
69#endif
70    case OBJECTS_ERROR:
71      break;
72  }
73
74  return ESRCH;
75}
Note: See TracBrowser for help on using the repository browser.