source: rtems/testsuites/sptests/sp24/task1.c @ 9b6362da

Last change on this file since 9b6362da was 9b6362da, checked in by Sebastian Huber <sebastian.huber@…>, on 11/18/21 at 11:13:53

rtems: Use RTEMS_WHO_AM_I for rtems_task_ident()

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*  Task_1_through_3
2 *
3 *  This task is a cyclic version of test1 to asssure that the times
4 *  displayed are not skewed as in test1.  "TA1" is printed once every
5 *  5 seconds, "TA2" is printed once every 10 seconds, and "TA3" is
6 *  printed once every 15 seconds.  The times displayed should be
7 *  in multiples of 5, 10, and 15 for TA1, TA2, and TA3 respectively.
8 *  If the times are skewed from these values, then the calendar time
9 *  does not correspond correctly with the number of ticks.
10 *
11 *  COPYRIGHT (c) 1989-2009.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "system.h"
24
25rtems_task Task_1_through_3(
26  rtems_task_argument argument
27)
28{
29  rtems_id          tid;
30  rtems_time_of_day time;
31  rtems_status_code status;
32
33  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
34  directive_failed( status, "rtems_task_ident of self" );
35
36  while ( FOREVER )  {
37    status = rtems_timer_fire_after(
38      Timer_id[ argument ],
39      task_number( tid ) * 5 * rtems_clock_get_ticks_per_second(),
40      Resume_task,
41      NULL
42    );
43    directive_failed( status, "tm_fire_after failed" );
44
45    status = rtems_clock_get_tod( &time );
46    directive_failed( status, "rtems_clock_get_tod failed" );
47
48    if ( time.second >= 35 ) {
49      TEST_END();
50      rtems_test_exit( 0 );
51    }
52
53    put_name( Task_name[ task_number( tid ) ], FALSE );
54    print_time( " - rtems_clock_get_tod - ", &time, "\n" );
55
56    status = rtems_task_suspend( RTEMS_SELF );
57    directive_failed( status, "rtems_task_suspend" );
58  }
59}
Note: See TracBrowser for help on using the repository browser.