1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2011. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifdef HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <tmacros.h> |
---|
17 | #include "test_support.h" |
---|
18 | #include <pthread.h> |
---|
19 | |
---|
20 | int Index; |
---|
21 | |
---|
22 | void *TestThread( |
---|
23 | void *argument |
---|
24 | ) |
---|
25 | { |
---|
26 | int *index = (int *)argument; |
---|
27 | |
---|
28 | *index = 7; |
---|
29 | |
---|
30 | puts( "TestThread exiting" ); |
---|
31 | return argument; |
---|
32 | } |
---|
33 | |
---|
34 | void *POSIX_Init( |
---|
35 | rtems_task_argument argument |
---|
36 | ) |
---|
37 | { |
---|
38 | int status; |
---|
39 | pthread_t id; |
---|
40 | pthread_attr_t attr; |
---|
41 | void *join_return; |
---|
42 | |
---|
43 | puts( "\n\n*** POSIX TEST PSX16 ***" ); |
---|
44 | |
---|
45 | Index = 5; |
---|
46 | |
---|
47 | /* Initialize and set thread detached attribute */ |
---|
48 | pthread_attr_init(&attr); |
---|
49 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); |
---|
50 | |
---|
51 | puts( "Creating TestThread" ); |
---|
52 | status = pthread_create( &id, &attr, TestThread, (void *)&Index ); |
---|
53 | rtems_test_assert( status == 0 ); |
---|
54 | |
---|
55 | /* let test thread run and exit */ |
---|
56 | puts( "Let TestThread run and exit before we attempt to join" ); |
---|
57 | sleep( 2 ); |
---|
58 | |
---|
59 | join_return = NULL; |
---|
60 | status = pthread_join( id, &join_return ); |
---|
61 | rtems_test_assert( status == 0 ); |
---|
62 | rtems_test_assert( join_return == &Index ); |
---|
63 | rtems_test_assert( *(int *)join_return == 7 ); |
---|
64 | puts( "Successfully joined with TestThread" ); |
---|
65 | |
---|
66 | puts( "*** END OF POSIX TEST PSX16 ***" ); |
---|
67 | |
---|
68 | rtems_test_exit(0); |
---|
69 | } |
---|
70 | |
---|
71 | /* configuration information */ |
---|
72 | |
---|
73 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
74 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
75 | |
---|
76 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 2 |
---|
77 | |
---|
78 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
79 | |
---|
80 | #define CONFIGURE_INIT |
---|
81 | #include <rtems/confdefs.h> |
---|
82 | /* end of file */ |
---|