1 | /* FP_task |
---|
2 | * |
---|
3 | * This routine serves as a floating point test task. It verifies the |
---|
4 | * basic task switching capabilities of the executive when floating |
---|
5 | * point is configured. |
---|
6 | * |
---|
7 | * Input parameters: |
---|
8 | * argument - task argument |
---|
9 | * |
---|
10 | * Output parameters: NONE |
---|
11 | * |
---|
12 | * COPYRIGHT (c) 1989-2009. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.com/license/LICENSE. |
---|
18 | * |
---|
19 | * $Id$ |
---|
20 | */ |
---|
21 | |
---|
22 | #include "system.h" |
---|
23 | #include "fptest.h" |
---|
24 | #include "inttest.h" |
---|
25 | |
---|
26 | rtems_task FP_task( |
---|
27 | rtems_task_argument argument |
---|
28 | ) |
---|
29 | { |
---|
30 | rtems_status_code status; |
---|
31 | rtems_id tid; |
---|
32 | rtems_time_of_day time; |
---|
33 | uint32_t task_index; |
---|
34 | uint32_t previous_seconds; |
---|
35 | INTEGER_DECLARE; |
---|
36 | FP_DECLARE; |
---|
37 | |
---|
38 | status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid ); |
---|
39 | directive_failed( status, "rtems_task_ident of self" ); |
---|
40 | |
---|
41 | task_index = task_number( tid ); |
---|
42 | |
---|
43 | INTEGER_LOAD( INTEGER_factors[ task_index ] ); |
---|
44 | FP_LOAD( FP_factors[ task_index ] ); |
---|
45 | |
---|
46 | put_name( Task_name[ task_index ], FALSE ); |
---|
47 | printf( " - integer base = (0x%x)\n", INTEGER_factors[ task_index ] ); |
---|
48 | put_name( Task_name[ task_index ], FALSE ); |
---|
49 | #if ( RTEMS_HAS_HARDWARE_FP == 1 ) |
---|
50 | printf( " - float base = (%g)\n", FP_factors[ task_index ] ); |
---|
51 | #else |
---|
52 | printf( " - float base = (NA)\n" ); |
---|
53 | #endif |
---|
54 | |
---|
55 | previous_seconds = (uint32_t)-1; |
---|
56 | |
---|
57 | while( FOREVER ) { |
---|
58 | |
---|
59 | status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time ); |
---|
60 | directive_failed( status, "rtems_clock_get" ); |
---|
61 | |
---|
62 | if ( time.second >= 16 ) { |
---|
63 | |
---|
64 | if ( task_number( tid ) == 4 ) { |
---|
65 | puts( "TA4 - rtems_task_delete - self" ); |
---|
66 | status = rtems_task_delete( RTEMS_SELF ); |
---|
67 | directive_failed( status, "rtems_task_delete of TA4" ); |
---|
68 | } |
---|
69 | puts( "TA5 - rtems_task_delete - TA3" ); |
---|
70 | status = rtems_task_delete( Task_id[ 3 ] ); |
---|
71 | directive_failed( status, "rtems_task_delete of TA3" ); |
---|
72 | |
---|
73 | puts( "*** END OF TEST 19 *** " ); |
---|
74 | rtems_test_exit( 0 ); |
---|
75 | } |
---|
76 | |
---|
77 | if (previous_seconds != time.second) |
---|
78 | { |
---|
79 | put_name( Task_name[ task_index ], FALSE ); |
---|
80 | print_time( " - rtems_clock_get - ", &time, "\n" ); |
---|
81 | previous_seconds = time.second; |
---|
82 | } |
---|
83 | |
---|
84 | INTEGER_CHECK( INTEGER_factors[ task_index ] ); |
---|
85 | FP_CHECK( FP_factors[ task_index ] ); |
---|
86 | |
---|
87 | /* for the first 4 seconds we spin as fast as possible |
---|
88 | * so that we likely are interrupted |
---|
89 | * After that, we go to sleep for a second at a time |
---|
90 | */ |
---|
91 | if (time.second >= 4) |
---|
92 | { |
---|
93 | status = rtems_task_wake_after( TICKS_PER_SECOND ); |
---|
94 | directive_failed( status, "rtems_task_wake_after" ); |
---|
95 | } |
---|
96 | } |
---|
97 | } |
---|