source: rtems/testsuites/psxtests/psx01/task.c @ 39615f4

4.104.115
Last change on this file since 39615f4 was 39615f4, checked in by Ralf Corsepius <ralf.corsepius@…>, on 10/27/09 at 14:10:54

Use PRIxpthread_t to print pthread_t's.

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