source: rtems/testsuites/sptests/sp19/fptask.c @ 6c0301d

4.115
Last change on this file since 6c0301d was 6c0301d, checked in by Sebastian Huber <sebastian.huber@…>, on 03/25/14 at 07:06:21

tests/sptests: Use <rtems/test.h>

  • Property mode set to 100644
File size: 2.4 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_SELF, 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  #if ( RTEMS_HAS_HARDWARE_FP == 1 )
45    printf( " - float base = (%g)\n", FP_factors[ task_index ] );
46  #else
47    printf( " - float base = (NA)\n" );
48  #endif
49
50  previous_seconds = (uint32_t)-1;
51
52  while( FOREVER ) {
53
54    status = rtems_clock_get_tod( &time );
55    directive_failed( status, "rtems_clock_get_tod" );
56
57    if ( time.second >= 16 ) {
58      if ( task_number( tid ) == 4 ) {
59        puts( "TA4 - rtems_task_delete - self" );
60        status = rtems_task_delete( RTEMS_SELF );
61        directive_failed( status, "rtems_task_delete of TA4" );
62      }
63      puts( "TA5 - rtems_task_delete - TA3" );
64      status = rtems_task_delete( Task_id[ 3 ] );
65      directive_failed( status, "rtems_task_delete of TA3" );
66
67      TEST_END();
68      rtems_test_exit( 0 );
69    }
70
71    if (previous_seconds != time.second) {
72      put_name( Task_name[ task_index ], FALSE );
73      print_time( " - rtems_clock_get_tod - ", &time, "\n" );
74      previous_seconds = time.second;
75    }
76
77    INTEGER_CHECK( INTEGER_factors[ task_index ] );
78    FP_CHECK( FP_factors[ task_index ] );
79
80    /* for the first 4 seconds we spin as fast as possible
81     * so that we likely are interrupted
82     * After that, we go to sleep for a second at a time
83     */
84    if (time.second >= 4) {
85      status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
86      directive_failed( status, "rtems_task_wake_after" );
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.