source: rtems/c/src/tests/psxtests/psx01/task.c @ 60b791ad

4.104.114.84.95
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on 02/17/98 at 23:46:28

updated copyright to 1998

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*  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-1998.
12 *  On-Line Applications Research Corporation (OAR).
13 *  Copyright assigned to U.S. Government, 1994.
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.OARcorp.com/rtems/license.html.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24void Test_init_routine( void )
25{
26  puts( "Test_init_routine: invoked" );
27}
28
29
30void *Task_1_through_3(
31  void *argument
32)
33{
34  int            status;
35  pthread_once_t once = PTHREAD_ONCE_INIT;
36
37  puts( "Task_1: sched_yield to Init" );
38  status = sched_yield();
39  assert( !status );
40 
41    /* switch to Task_1 */
42
43  /* now do some real testing */
44
45  empty_line();
46
47  /* get id of this thread */
48
49  Task_id = pthread_self();
50  printf( "Task_1: ID is 0x%08x\n", Task_id );
51
52  /* exercise pthread_equal */
53
54  status = pthread_equal( Task_id, Task_id );
55  if ( status )
56    puts( "Task_1: pthread_equal - match case passed" );
57  assert( status );
58
59  status = pthread_equal( Init_id, Task_id );
60  if ( !status )
61    puts( "Task_1: pthread_equal - different case passed" );
62  assert( !status );
63
64  puts( "Task_1: pthread_equal - first id bad" );
65  status = pthread_equal( -1, Task_id );
66  assert( !status );
67
68  puts( "Task_1: pthread_equal - second id bad" );
69  status = pthread_equal( Init_id, -1 );
70  assert( !status );
71
72  /* exercise pthread_once */
73
74  puts( "Task_1: pthread_once - EINVAL (NULL once_control)" );
75  status = pthread_once( NULL, Test_init_routine );
76  assert( status == EINVAL );
77
78  puts( "Task_1: pthread_once - EINVAL (NULL init_routine)" );
79  status = pthread_once( &once, NULL );
80  assert( status == EINVAL );
81
82  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine executes)" );
83  status = pthread_once( &once, Test_init_routine );
84  assert( !status );
85
86  puts( "Task_1: pthread_once - SUCCESSFUL (init_routine does not execute)" );
87  status = pthread_once( &once, Test_init_routine );
88  assert( !status );
89
90  puts( "*** END OF POSIX TEST 1 ***" );
91  exit( 0 );
92
93  return NULL; /* just so the compiler thinks we returned something */
94}
Note: See TracBrowser for help on using the repository browser.