source: rtems/testsuites/psxtests/psx08/init.c @ 749eae97

4.104.115
Last change on this file since 749eae97 was 2e7e636f, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/09 at 01:41:16

2009-05-10 Joel Sherrill <joel.sherrill@…>

  • psx01/init.c, psx01/task.c, psx02/init.c, psx02/task.c, psx03/init.c, psx04/init.c, psx04/task1.c, psx04/task3.c, psx05/init.c, psx06/init.c, psx07/init.c, psx08/init.c, psx09/init.c, psx11/task.c, psx12/init.c, psx13/main.c, psx13/test.c, psxbarrier01/test.c, psxcancel/init.c, psxcleanup/psxcleanup.c, psxenosys/init.c, psxmsgq02/init.c, psxtime/main.c, psxtime/test.c, psxtimer01/psxtimer.c, psxtimer02/psxtimer.c: Fix warnings.
  • 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%08x\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.