OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [psxtests/] [psx08/] [init.c] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  COPYRIGHT (c) 1989-1999.
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.OARcorp.com/rtems/license.html.
8
 *
9
 *  $Id: init.c,v 1.2 2001-09-27 12:02:24 chris Exp $
10
 */
11
 
12
#define CONFIGURE_INIT
13
#include "system.h"
14
#include <errno.h>
15
 
16
void *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( -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( -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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.