source: rtems/testsuites/sptests/sp19/fptask.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: 2.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include "system.h"
15#include "fptest.h"
16#include "inttest.h"
17
18rtems_task FP_task(
19  rtems_task_argument argument
20)
21{
22  rtems_status_code status;
23  rtems_id          tid;
24  rtems_time_of_day time;
25  uint32_t          task_index;
26  uint32_t          previous_seconds;
27  INTEGER_DECLARE;
28  FP_DECLARE;
29
30  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
31  directive_failed( status, "rtems_task_ident of self" );
32
33  task_index = task_number( tid );
34
35  INTEGER_LOAD( INTEGER_factors[ task_index ] );
36  FP_LOAD( FP_factors[ task_index ] );
37
38  put_name( Task_name[ task_index ], FALSE );
39  printf(
40    " - integer base = (0x%" PRIx32 ")\n",
41    INTEGER_factors[ task_index ]
42  );
43  put_name( Task_name[ task_index ], FALSE );
44  printf( " - float base = (%g)\n", FP_factors[ task_index ] );
45
46  previous_seconds = (uint32_t)-1;
47
48  while( FOREVER ) {
49
50    status = rtems_clock_get_tod( &time );
51    directive_failed( status, "rtems_clock_get_tod" );
52
53    if ( time.second >= 16 ) {
54      if ( task_number( tid ) == 4 ) {
55        puts( "TA4 - rtems_task_exit" );
56        rtems_task_exit();
57      }
58      puts( "TA5 - rtems_task_delete - TA3" );
59      status = rtems_task_delete( Task_id[ 3 ] );
60      directive_failed( status, "rtems_task_delete of TA3" );
61
62      TEST_END();
63      rtems_test_exit( 0 );
64    }
65
66    if (previous_seconds != time.second) {
67      put_name( Task_name[ task_index ], FALSE );
68      print_time( " - rtems_clock_get_tod - ", &time, "\n" );
69      previous_seconds = time.second;
70    }
71
72    INTEGER_CHECK( INTEGER_factors[ task_index ] );
73    FP_CHECK( FP_factors[ task_index ] );
74
75    /* for the first 4 seconds we spin as fast as possible
76     * so that we likely are interrupted
77     * After that, we go to sleep for a second at a time
78     */
79    if (time.second >= 4) {
80      status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
81      directive_failed( status, "rtems_task_wake_after" );
82    }
83  }
84}
Note: See TracBrowser for help on using the repository browser.