source: rtems/testsuites/psxtests/psx08/init.c @ e1a7627

4.104.115
Last change on this file since e1a7627 was 39615f4, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/27/09 at 14:10:54

Use PRIxpthread_t to print pthread_t's.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
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#define CONFIGURE_INIT
13#include "system.h"
14#include <errno.h>
15
16void *POSIX_Init(
17  void *argument
18)
19{
20  int    status;
21  void  *return_pointer;
22
23  puts( "\n\n*** POSIX TEST 8 ***" );
24
25  /* set the time of day, and print our buffer in multiple ways */
26
27  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
28
29  /* get id of this thread */
30
31  Init_id = pthread_self();
32  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
33
34  puts( "Init: pthread_detach - ESRCH (invalid id)" );
35  status = pthread_detach( (pthread_t) -1 );
36  assert( status == ESRCH );
37
38  /* detach this thread */
39
40  puts( "Init: pthread_detach self" );
41  status = pthread_detach( pthread_self() );
42  assert( !status );
43
44  /* create thread */
45
46  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
47  assert( !status );
48
49  puts( "Init: pthread_join - ESRCH (invalid id)" );
50  status = pthread_join( (pthread_t) -1, &return_pointer );
51  assert( status == ESRCH );
52
53  puts( "Init: pthread_join - SUCCESSFUL" );
54  status = pthread_join( Task1_id, &return_pointer );
55
56  puts( "Init: returned from pthread_join through return" );
57  if ( status )
58    printf( "status = %d\n", status );
59  assert( !status );
60
61  if ( return_pointer == &Task1_id )
62    puts( "Init: pthread_join returned correct pointer" );
63  else
64    printf(
65      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
66      return_pointer,
67      &Task1_id
68    );
69
70  puts( "Init: creating two pthreads" );
71  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
72  assert( !status );
73
74  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
75  assert( !status );
76
77  puts( "Init: pthread_join - SUCCESSFUL" );
78  status = pthread_join( Task2_id, &return_pointer );
79  /* assert is below comment */
80
81  puts( "Init: returned from pthread_join through pthread_exit" );
82  if ( status )
83    printf( "status = %d\n", status );
84  assert( !status );
85
86  if ( return_pointer == &Task2_id )
87    puts( "Init: pthread_join returned correct pointer" );
88  else
89    printf(
90      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
91      return_pointer,
92      &Task2_id
93    );
94
95  puts( "Init: exitting" );
96  return NULL;
97}
Note: See TracBrowser for help on using the repository browser.