source: rtems/testsuites/sptests/sp19/fptask.c

Last change on this file was eb57966, checked in by Joel Sherrill <joel@…>, on 03/31/22 at 21:32:14

testsuites/sptests/sp1*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include "system.h"
34#include "fptest.h"
35#include "inttest.h"
36
37rtems_task FP_task(
38  rtems_task_argument argument
39)
40{
41  rtems_status_code status;
42  rtems_id          tid;
43  rtems_time_of_day time;
44  uint32_t          task_index;
45  uint32_t          previous_seconds;
46  INTEGER_DECLARE;
47  FP_DECLARE;
48
49  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
50  directive_failed( status, "rtems_task_ident of self" );
51
52  task_index = task_number( tid );
53
54  INTEGER_LOAD( INTEGER_factors[ task_index ] );
55  FP_LOAD( FP_factors[ task_index ] );
56
57  put_name( Task_name[ task_index ], FALSE );
58  printf(
59    " - integer base = (0x%" PRIx32 ")\n",
60    INTEGER_factors[ task_index ]
61  );
62  put_name( Task_name[ task_index ], FALSE );
63  printf( " - float base = (%g)\n", FP_factors[ task_index ] );
64
65  previous_seconds = (uint32_t)-1;
66
67  while( FOREVER ) {
68
69    status = rtems_clock_get_tod( &time );
70    directive_failed( status, "rtems_clock_get_tod" );
71
72    if ( time.second >= 16 ) {
73      if ( task_number( tid ) == 4 ) {
74        puts( "TA4 - rtems_task_exit" );
75        rtems_task_exit();
76      }
77      puts( "TA5 - rtems_task_delete - TA3" );
78      status = rtems_task_delete( Task_id[ 3 ] );
79      directive_failed( status, "rtems_task_delete of TA3" );
80
81      TEST_END();
82      rtems_test_exit( 0 );
83    }
84
85    if (previous_seconds != time.second) {
86      put_name( Task_name[ task_index ], FALSE );
87      print_time( " - rtems_clock_get_tod - ", &time, "\n" );
88      previous_seconds = time.second;
89    }
90
91    INTEGER_CHECK( INTEGER_factors[ task_index ] );
92    FP_CHECK( FP_factors[ task_index ] );
93
94    /* for the first 4 seconds we spin as fast as possible
95     * so that we likely are interrupted
96     * After that, we go to sleep for a second at a time
97     */
98    if (time.second >= 4) {
99      status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
100      directive_failed( status, "rtems_task_wake_after" );
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.