OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [psxtests/] [psx01/] [task.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  Task_1_through_3
2
 *
3
 *  This routine serves as a test task.  It verifies the basic task
4
 *  switching capabilities of the executive.
5
 *
6
 *  Input parameters:
7
 *    argument - task argument
8
 *
9
 *  Output parameters:  NONE
10
 *
11
 *  COPYRIGHT (c) 1989-1999.
12
 *  On-Line Applications Research Corporation (OAR).
13
 *
14
 *  The license and distribution terms for this file may be
15
 *  found in the file LICENSE in this distribution or at
16
 *  http://www.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: task.c,v 1.2 2001-09-27 12:02:23 chris Exp $
19
 */
20
 
21
#include "system.h"
22
 
23
void Test_init_routine( void )
24
{
25
  puts( "Test_init_routine: invoked" );
26
}
27
 
28
 
29
void *Task_1_through_3(
30
  void *argument
31
)
32
{
33
  int            status;
34
  pthread_once_t once = PTHREAD_ONCE_INIT;
35
 
36
  puts( "Task_1: sched_yield to Init" );
37
  status = sched_yield();
38
  assert( !status );
39
 
40
    /* switch to Task_1 */
41
 
42
  /* now do some real testing */
43
 
44
  empty_line();
45
 
46
  /* get id of this thread */
47
 
48
  Task_id = pthread_self();
49
  printf( "Task_1: ID is 0x%08x\n", Task_id );
50
 
51
  /* exercise pthread_equal */
52
 
53
  status = pthread_equal( Task_id, Task_id );
54
  if ( status )
55
    puts( "Task_1: pthread_equal - match case passed" );
56
  assert( status );
57
 
58
  status = pthread_equal( Init_id, Task_id );
59
  if ( !status )
60
    puts( "Task_1: pthread_equal - different case passed" );
61
  assert( !status );
62
 
63
  puts( "Task_1: pthread_equal - first id bad" );
64
  status = pthread_equal( -1, Task_id );
65
  assert( !status );
66
 
67
  puts( "Task_1: pthread_equal - second id bad" );
68
  status = pthread_equal( Init_id, -1 );
69
  assert( !status );
70
 
71
  /* exercise pthread_once */
72
 
73
  puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
74
  status = pthread_once( NULL, Test_init_routine );
75
  assert( status == EINVAL );
76
 
77
  puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
78
  status = pthread_once( &once, NULL );
79
  assert( status == EINVAL );
80
 
81
  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
82
  status = pthread_once( &once, Test_init_routine );
83
  assert( !status );
84
 
85
  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
86
  status = pthread_once( &once, Test_init_routine );
87
  assert( !status );
88
 
89
  puts( "*** END OF POSIX TEST 1 ***" );
90
  exit( 0 );
91
 
92
  return NULL; /* just so the compiler thinks we returned something */
93
}

powered by: WebSVN 2.1.0

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