1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2013. |
---|
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 | #if !defined(OPERATION_COUNT) |
---|
11 | #define OPERATION_COUNT 100 |
---|
12 | #endif |
---|
13 | |
---|
14 | #ifdef HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <rtems/btimer.h> |
---|
19 | |
---|
20 | #define CONFIGURE_INIT |
---|
21 | #include "system.h" |
---|
22 | |
---|
23 | const char rtems_test_name[] = "TIME TEST 24"; |
---|
24 | |
---|
25 | uint32_t Task_count; |
---|
26 | |
---|
27 | rtems_task Tasks( |
---|
28 | rtems_task_argument argument |
---|
29 | ); |
---|
30 | |
---|
31 | rtems_task High_task( |
---|
32 | rtems_task_argument argument |
---|
33 | ); |
---|
34 | |
---|
35 | rtems_task Init( |
---|
36 | rtems_task_argument argument |
---|
37 | ) |
---|
38 | { |
---|
39 | rtems_id id; |
---|
40 | uint32_t index; |
---|
41 | rtems_status_code status; |
---|
42 | |
---|
43 | Print_Warning(); |
---|
44 | |
---|
45 | TEST_BEGIN(); |
---|
46 | |
---|
47 | status = rtems_task_create( |
---|
48 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
49 | 1, |
---|
50 | RTEMS_MINIMUM_STACK_SIZE, |
---|
51 | RTEMS_DEFAULT_MODES, |
---|
52 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
53 | &id |
---|
54 | ); |
---|
55 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
56 | |
---|
57 | status = rtems_task_start( id, High_task, 0 ); |
---|
58 | directive_failed( status, "rtems_task_create HIGH" ); |
---|
59 | |
---|
60 | for ( index = 1 ; index <= OPERATION_COUNT ; index++ ) { |
---|
61 | status = rtems_task_create( |
---|
62 | rtems_build_name( 'R', 'E', 'S', 'T' ), |
---|
63 | (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u, |
---|
64 | RTEMS_MINIMUM_STACK_SIZE, |
---|
65 | RTEMS_DEFAULT_MODES, |
---|
66 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
67 | &id |
---|
68 | ); |
---|
69 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
70 | |
---|
71 | status = rtems_task_start( id, Tasks, 0 ); |
---|
72 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
73 | } |
---|
74 | rtems_task_exit(); |
---|
75 | } |
---|
76 | |
---|
77 | rtems_task High_task( |
---|
78 | rtems_task_argument argument |
---|
79 | ) |
---|
80 | { |
---|
81 | uint32_t index; |
---|
82 | |
---|
83 | benchmark_timer_initialize(); |
---|
84 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
85 | (void) benchmark_timer_empty_function(); |
---|
86 | overhead = benchmark_timer_read(); |
---|
87 | |
---|
88 | benchmark_timer_initialize(); |
---|
89 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
90 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
91 | end_time = benchmark_timer_read(); |
---|
92 | |
---|
93 | put_time( |
---|
94 | "rtems_task_wake_after: yield returns to caller", |
---|
95 | end_time, |
---|
96 | OPERATION_COUNT, |
---|
97 | overhead, |
---|
98 | 0 |
---|
99 | ); |
---|
100 | |
---|
101 | Task_count = 0; |
---|
102 | |
---|
103 | rtems_task_exit(); |
---|
104 | } |
---|
105 | |
---|
106 | rtems_task Tasks( |
---|
107 | rtems_task_argument argument |
---|
108 | ) |
---|
109 | { |
---|
110 | Task_count++; |
---|
111 | |
---|
112 | if ( Task_count == 1 ) |
---|
113 | benchmark_timer_initialize(); |
---|
114 | else if ( Task_count == OPERATION_COUNT ) { |
---|
115 | end_time = benchmark_timer_read(); |
---|
116 | |
---|
117 | put_time( |
---|
118 | "rtems_task_wake_after: yields preempts caller", |
---|
119 | end_time, |
---|
120 | OPERATION_COUNT, |
---|
121 | overhead, |
---|
122 | 0 |
---|
123 | ); |
---|
124 | |
---|
125 | TEST_END(); |
---|
126 | rtems_test_exit( 0 ); |
---|
127 | } |
---|
128 | (void) rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
129 | } |
---|