source: rtems/testsuites/mptests/mp01/task1.c @ 4b374f36

4.104.114.84.95
Last change on this file since 4b374f36 was 88d594a, checked in by Joel Sherrill <joel.sherrill@…>, on 05/24/95 at 21:39:42

Fully tested on all in-house targets

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*  Test_task
2 *
3 *  This task is used for three test tasks.  It obtains its task id and
4 *  based upon that id, performs certain actions.
5 *
6 *       Task_1 delays 5 seconds and deletes itself.
7 *       Task_2 delays 10 seconds and then loops until
8 *             deleted by the third task.
9 *       Task 3 delays 15 seconds, then deletes task 2 and itself.
10 *
11 *  Input parameters:
12 *    argument - task argument
13 *
14 *  Output parameters:  NONE
15 *
16 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
17 *  On-Line Applications Research Corporation (OAR).
18 *  All rights assigned to U.S. Government, 1994.
19 *
20 *  This material may be reproduced by or for the U.S. Government pursuant
21 *  to the copyright license under the clause at DFARS 252.227-7013.  This
22 *  notice must appear in all copies of this file and its derivatives.
23 *
24 *  task1.c,v 1.2 1995/05/09 20:26:24 joel Exp
25 */
26
27#include "system.h"
28
29rtems_task Test_task(
30  rtems_task_argument argument
31)
32{
33  rtems_status_code status;
34  rtems_id          tid;
35  rtems_time_of_day time;
36
37  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
38  directive_failed( status, "rtems_task_ident" );
39
40  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
41  directive_failed( status, "rtems_clock_get" );
42
43  put_name( Task_name[ task_number( tid ) ], FALSE );
44  print_time( " - rtems_clock_get - ", &time, "\n" );
45
46  status = rtems_task_wake_after( task_number( tid ) * 1 * TICKS_PER_SECOND );
47  directive_failed( status, "rtems_task_wake_after" );
48
49  status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
50  directive_failed( status, "rtems_clock_get" );
51  put_name( Task_name[ task_number( tid ) ], FALSE );
52  print_time( " - rtems_clock_get - ", &time, "\n" );
53
54  if ( task_number(tid) == 1 ) {          /* TASK 1 */
55    put_name( Task_name[ 1 ], FALSE );
56    printf( " - deleting self\n" );
57    status = rtems_task_delete( RTEMS_SELF );
58    directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
59  }
60  else if ( task_number(tid) == 2 ) {     /* TASK 2 */
61    put_name( Task_name[ 2 ], FALSE );
62    printf( " - waiting to be deleted by " );
63    put_name( Task_name[ 3 ], TRUE );
64    while ( FOREVER );
65  }
66  else {                                  /* TASK 3 */
67    put_name( Task_name[ 3 ], FALSE );
68    printf( " - getting TID of " );
69    put_name( Task_name[ 2 ], TRUE );
70    do {
71      status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid );
72    } while ( status != RTEMS_SUCCESSFUL );
73    directive_failed( status, "rtems_task_ident" );
74
75    put_name( Task_name[ 3 ], FALSE );
76    printf( " - deleting " );
77    put_name( Task_name[ 2 ], TRUE );
78    status = rtems_task_delete( tid );
79    directive_failed( status, "rtems_task_delete of Task 2" );
80
81    puts( "*** END OF TEST 1 ***" );
82    exit(0);
83  }
84}
Note: See TracBrowser for help on using the repository browser.