source: rtems/testsuites/psxtests/psx08/init.c @ 03f2154e

4.104.114.84.9
Last change on this file since 03f2154e was 03f2154e, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 22, 1997 at 5:20:27 PM

headers updated to reflect new style copyright notice as part
of switching to the modified GNU GPL.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-1997.
3 *  On-Line Applications Research Corporation (OAR).
4 *  Copyright assigned to U.S. Government, 1994.
5 *
6 *  The license and distribution terms for this file may in
7 *  the file LICENSE in this distribution or at
8 *  http://www.OARcorp.com/rtems/license.html.
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
35  puts( "Init: pthread_detach - ESRCH (invalid id)" );
36  status = pthread_detach( -1 );
37  assert( status == ESRCH );
38
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 
47  puts( "Init: creating two tasks" );
48  status = pthread_create( &Task_id, NULL, Task_1, NULL );
49  assert( !status );
50 
51  status = pthread_create( &Task2_id, NULL, Task_2, NULL );
52  assert( !status );
53 
54  puts( "Init: pthread_join - ESRCH (invalid id)" );
55  status = pthread_join( -1, &return_pointer );
56  assert( status == ESRCH );
57
58  puts( "Init: pthread_join - SUCCESSFUL" );
59  status = pthread_join( Task_id, &return_pointer );
60  /* assert is below comment */
61
62     /* switch to Task 1 */
63
64  puts( "Init: returned from pthread_join" );
65  if ( status )
66    printf( "status = %d\n", status );
67  assert( !status );
68
69  if ( return_pointer == &Task_id )
70    puts( "Init: pthread_join returned correct pointer" );
71  else
72    printf(
73      "Init: pthread_join returned incorrect pointer (%p != %p)\n",
74      return_pointer,
75      &Task_id
76    );
77 
78  puts( "Init: exitting" );
79  pthread_exit( NULL );
80
81  return NULL; /* just so the compiler thinks we returned something */
82}
Note: See TracBrowser for help on using the repository browser.