source: rtems/testsuites/mptests/mp01/task1.c @ 8776bb9

5
Last change on this file since 8776bb9 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • 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-2009.
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.org/license/LICENSE.
22 */
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#include "system.h"
29
30rtems_task Test_task(
31  rtems_task_argument argument
32)
33{
34  rtems_status_code status;
35  rtems_id          tid;
36  rtems_time_of_day time;
37
38  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
39  directive_failed( status, "rtems_task_ident" );
40
41  status = rtems_clock_get_tod( &time );
42  directive_failed( status, "rtems_clock_get_tod" );
43
44  put_name( Task_name[ task_number( tid ) ], FALSE );
45  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
46
47  status = rtems_task_wake_after( task_number( tid ) * 1 * rtems_clock_get_ticks_per_second() );
48  directive_failed( status, "rtems_task_wake_after" );
49
50  status = rtems_clock_get_tod( &time );
51  directive_failed( status, "rtems_clock_get_tod" );
52  put_name( Task_name[ task_number( tid ) ], FALSE );
53  print_time( " - rtems_clock_get_tod - ", &time, "\n" );
54
55  if ( task_number(tid) == 1 ) {          /* TASK 1 */
56    put_name( Task_name[ 1 ], FALSE );
57    printf( " - deleting self\n" );
58    status = rtems_task_delete( RTEMS_SELF );
59    directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
60  }
61  else if ( task_number(tid) == 2 ) {     /* TASK 2 */
62    put_name( Task_name[ 2 ], FALSE );
63    printf( " - waiting to be deleted by " );
64    put_name( Task_name[ 3 ], TRUE );
65    while ( FOREVER );
66  }
67  else {                                  /* TASK 3 */
68    put_name( Task_name[ 3 ], FALSE );
69    printf( " - getting TID of " );
70    put_name( Task_name[ 2 ], TRUE );
71    do {
72      status = rtems_task_ident( Task_name[ 2 ], RTEMS_SEARCH_ALL_NODES, &tid );
73    } while ( status != RTEMS_SUCCESSFUL );
74    directive_failed( status, "rtems_task_ident" );
75
76    put_name( Task_name[ 3 ], FALSE );
77    printf( " - deleting " );
78    put_name( Task_name[ 2 ], TRUE );
79    status = rtems_task_delete( tid );
80    directive_failed( status, "rtems_task_delete of Task 2" );
81
82    puts( "*** END OF TEST 1 ***" );
83    rtems_test_exit(0);
84  }
85}
Note: See TracBrowser for help on using the repository browser.