OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [pthreadjoin.c] - Blame information for rev 158

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 158 chris
/*
2
 *  16.1.3 Wait for Thread Termination, P1003.1c/Draft 10, p. 147
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
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.OARcorp.com/rtems/license.html.
10
 *
11
 *  $Id: pthreadjoin.c,v 1.1.1.1 2001-07-10 09:42:59 chris Exp $
12
 */
13
 
14
 
15
#include <pthread.h>
16
#include <errno.h>
17
 
18
#include <rtems/system.h>
19
#include <rtems/score/thread.h>
20
#include <rtems/posix/pthread.h>
21
 
22
int pthread_join(
23
  pthread_t   thread,
24
  void      **value_ptr
25
)
26
{
27
  register Thread_Control *the_thread;
28
  POSIX_API_Control       *api;
29
  Objects_Locations        location;
30
  void                    *return_pointer;
31
 
32
  the_thread = _POSIX_Threads_Get( thread, &location );
33
  switch ( location ) {
34
    case OBJECTS_ERROR:
35
    case OBJECTS_REMOTE:
36
      return ESRCH;
37
    case OBJECTS_LOCAL:
38
      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
39
 
40
      if ( api->detachstate == PTHREAD_CREATE_DETACHED ) {
41
        _Thread_Enable_dispatch();
42
        return EINVAL;
43
      }
44
 
45
      if ( _Thread_Is_executing( the_thread ) ) {
46
        _Thread_Enable_dispatch();
47
        return EDEADLK;
48
      }
49
 
50
      /*
51
       *  Put ourself on the threads join list
52
       */
53
 
54
      _Thread_Executing->Wait.return_argument = (unsigned32 *) &return_pointer;
55
 
56
      _Thread_queue_Enter_critical_section( &api->Join_List );
57
 
58
      _Thread_queue_Enqueue( &api->Join_List, WATCHDOG_NO_TIMEOUT );
59
 
60
      _Thread_Enable_dispatch();
61
 
62
      if ( value_ptr )
63
        *value_ptr = return_pointer;
64
      return 0;
65
  }
66
 
67
  return POSIX_BOTTOM_REACHED();
68
}
69
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.