source: rtems/testsuites/psxtests/psx08/init.c @ 20f54e9

4.104.114.84.95
Last change on this file since 20f54e9 was 7d96321, checked in by Joel Sherrill <joel.sherrill@…>, on 10/04/99 at 19:41:34

Modifications necessary to support testing of exitting a pthread from
Charles-Antione Gauthier <charles.gauthier@…>.

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[20de272]1/*
[60b791ad]2 *  COPYRIGHT (c) 1989-1998.
[20de272]3 *  On-Line Applications Research Corporation (OAR).
[03f2154e]4 *  Copyright assigned to U.S. Government, 1994.
[20de272]5 *
[98e4ebf5]6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
[03f2154e]8 *  http://www.OARcorp.com/rtems/license.html.
[20de272]9 *
10 *  $Id$
11 */
12
13#define CONFIGURE_INIT
14#include "system.h"
15#include <errno.h>
16
17void *POSIX_Init(
18  void *argument
19)
20{
21  int    status;
22  void  *return_pointer;
23
24  puts( "\n\n*** POSIX TEST 8 ***" );
25
26  /* set the time of day, and print our buffer in multiple ways */
27
28  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
29
30  /* get id of this thread */
31
32  Init_id = pthread_self();
33  printf( "Init's ID is 0x%08x\n", Init_id );
34
[42418a9]35  puts( "Init: pthread_detach - ESRCH (invalid id)" );
36  status = pthread_detach( -1 );
37  assert( status == ESRCH );
38
[20de272]39  /* detach this thread */
40
41  puts( "Init: pthread_detach self" );
42  status = pthread_detach( pthread_self() );
43  assert( !status );
44
45  /* create thread */
46 
[7d96321]47  status = pthread_create( &Task1_id, NULL, Task_1, NULL );
[20de272]48  assert( !status );
49 
[42418a9]50  puts( "Init: pthread_join - ESRCH (invalid id)" );
51  status = pthread_join( -1, &return_pointer );
52  assert( status == ESRCH );
53
[20de272]54  puts( "Init: pthread_join - SUCCESSFUL" );
[7d96321]55  status = pthread_join( Task1_id, &return_pointer );
[20de272]56
[7d96321]57  puts( "Init: returned from pthread_join through return" );
58  if ( status )
59    printf( "status = %d\n", status );
60  assert( !status );
[20de272]61
[7d96321]62  if ( return_pointer == &Task1_id )
63    puts( "Init: pthread_join returned correct pointer" );
64  else
65    printf(
66      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
67      return_pointer,
68      &Task1_id
69    );
70 
71  puts( "Init: creating two pthreads" );
72  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
73  assert( !status );
74 
75  status = pthread_create( &Task3_id, NULL, Task_3, NULL );
76  assert( !status );
77 
78  puts( "Init: pthread_join - SUCCESSFUL" );
79  status = pthread_join( Task2_id, &return_pointer );
80  /* assert is below comment */
81
82  puts( "Init: returned from pthread_join through pthread_exit" );
[20de272]83  if ( status )
84    printf( "status = %d\n", status );
85  assert( !status );
86
[7d96321]87  if ( return_pointer == &Task2_id )
[20de272]88    puts( "Init: pthread_join returned correct pointer" );
89  else
90    printf(
91      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
92      return_pointer,
[7d96321]93      &Task2_id
[20de272]94    );
95 
96  puts( "Init: exitting" );
[7d96321]97  return NULL;
[20de272]98}
Note: See TracBrowser for help on using the repository browser.