source: rtems/testsuites/mptests/mp01/task1.c @ 573f8d4

4.104.11
Last change on this file since 573f8d4 was 573f8d4, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 10, 2009 at 2:50:29 PM

2009-08-10 Joel Sherrill <joel.sherrill@…>

  • mp01/task1.c, mp01/node1/mp01-node1.scn, mp01/node2/mp01-node2.scn: Convert calls to legacy routine rtems_clock_get( RTEMS_CLOCK_GET_TOD, ..) to rtems_clock_get_tod(..).
  • Property mode set to 100644
File size: 2.6 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-1999.
17 *  On-Line Applications Research Corporation (OAR).
18 *
19 *  The license and distribution terms for this file may be
20 *  found in the file LICENSE in this distribution or at
21 *  http://www.rtems.com/license/LICENSE.
22 *
23 *  $Id$
24 */
25
26#include "system.h"
27
28rtems_task Test_task(
29  rtems_task_argument argument
30)
31{
32  rtems_status_code status;
33  rtems_id          tid;
34  rtems_time_of_day time;
35
36  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
37  directive_failed( status, "rtems_task_ident" );
38
39  status = rtems_clock_get_tod( &time );
40  directive_failed( status, "rtems_clock_get_tod" );
41
42  put_name( Task_name[ task_number( tid ) ], FALSE );
43  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
44
45  status = rtems_task_wake_after( task_number( tid ) * 1 * TICKS_PER_SECOND );
46  directive_failed( status, "rtems_task_wake_after" );
47
48  status = rtems_clock_get_tod( &time );
49  directive_failed( status, "rtems_clock_get_tod" );
50  put_name( Task_name[ task_number( tid ) ], FALSE );
51  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
52
53  if ( task_number(tid) == 1 ) {          /* TASK 1 */
54    put_name( Task_name[ 1 ], FALSE );
55    printf( " - deleting self\n" );
56    status = rtems_task_delete( RTEMS_SELF );
57    directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
58  }
59  else if ( task_number(tid) == 2 ) {     /* TASK 2 */
60    put_name( Task_name[ 2 ], FALSE );
61    printf( " - waiting to be deleted by " );
62    put_name( Task_name[ 3 ], TRUE );
63    while ( FOREVER );
64  }
65  else {                                  /* TASK 3 */
66    put_name( Task_name[ 3 ], FALSE );
67    printf( " - getting TID of " );
68    put_name( Task_name[ 2 ], TRUE );
69    do {
70      status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid );
71    } while ( status != RTEMS_SUCCESSFUL );
72    directive_failed( status, "rtems_task_ident" );
73
74    put_name( Task_name[ 3 ], FALSE );
75    printf( " - deleting " );
76    put_name( Task_name[ 2 ], TRUE );
77    status = rtems_task_delete( tid );
78    directive_failed( status, "rtems_task_delete of Task 2" );
79
80    puts( "*** END OF TEST 1 ***" );
81    rtems_test_exit(0);
82  }
83}
Note: See TracBrowser for help on using the repository browser.