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 10"; |
---|
24 | |
---|
25 | rtems_id Queue_id; |
---|
26 | long Buffer[4]; |
---|
27 | |
---|
28 | rtems_task High_task( |
---|
29 | rtems_task_argument argument |
---|
30 | ); |
---|
31 | |
---|
32 | rtems_task Middle_tasks( |
---|
33 | rtems_task_argument argument |
---|
34 | ); |
---|
35 | |
---|
36 | rtems_task Low_task( |
---|
37 | rtems_task_argument argument |
---|
38 | ); |
---|
39 | |
---|
40 | void test_init(void); |
---|
41 | |
---|
42 | int operation_count = OPERATION_COUNT; |
---|
43 | |
---|
44 | rtems_task Init( |
---|
45 | rtems_task_argument argument |
---|
46 | ) |
---|
47 | { |
---|
48 | Print_Warning(); |
---|
49 | |
---|
50 | TEST_BEGIN(); |
---|
51 | |
---|
52 | test_init(); |
---|
53 | |
---|
54 | rtems_task_exit(); |
---|
55 | } |
---|
56 | |
---|
57 | void test_init() |
---|
58 | { |
---|
59 | int index; |
---|
60 | size_t size; |
---|
61 | rtems_task_entry task_entry; |
---|
62 | rtems_status_code status; |
---|
63 | rtems_task_priority priority; |
---|
64 | rtems_id task_id; |
---|
65 | |
---|
66 | priority = 2; |
---|
67 | |
---|
68 | if ( OPERATION_COUNT > RTEMS_MAXIMUM_PRIORITY - 2 ) |
---|
69 | operation_count = RTEMS_MAXIMUM_PRIORITY - 2; |
---|
70 | |
---|
71 | for( index = 0; index < operation_count ; index++ ) { |
---|
72 | status = rtems_task_create( |
---|
73 | rtems_build_name( 'T', 'I', 'M', 'E' ), |
---|
74 | priority, |
---|
75 | RTEMS_MINIMUM_STACK_SIZE, |
---|
76 | RTEMS_DEFAULT_MODES, |
---|
77 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
78 | &task_id |
---|
79 | ); |
---|
80 | directive_failed( status, "rtems_task_create LOOP" ); |
---|
81 | |
---|
82 | priority++; |
---|
83 | |
---|
84 | if ( index==0 ) task_entry = High_task; |
---|
85 | else if ( index==operation_count-1 ) task_entry = Low_task; |
---|
86 | else task_entry = Middle_tasks; |
---|
87 | |
---|
88 | status = rtems_task_start( task_id, task_entry, 0 ); |
---|
89 | directive_failed( status, "rtems_task_start LOOP" ); |
---|
90 | } |
---|
91 | |
---|
92 | status = rtems_message_queue_create( |
---|
93 | 1, |
---|
94 | (uint32_t)operation_count, |
---|
95 | 16, |
---|
96 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
97 | &Queue_id |
---|
98 | ); |
---|
99 | directive_failed( status, "rtems_message_queue_create" ); |
---|
100 | |
---|
101 | benchmark_timer_initialize(); |
---|
102 | for ( index=1 ; index < operation_count ; index++ ) |
---|
103 | (void) benchmark_timer_empty_function(); |
---|
104 | overhead = benchmark_timer_read(); |
---|
105 | |
---|
106 | benchmark_timer_initialize(); |
---|
107 | for ( index=1 ; index < operation_count ; index++ ) |
---|
108 | (void) rtems_message_queue_receive( |
---|
109 | Queue_id, |
---|
110 | (long (*)[4]) Buffer, |
---|
111 | &size, |
---|
112 | RTEMS_NO_WAIT, |
---|
113 | RTEMS_NO_TIMEOUT |
---|
114 | ); |
---|
115 | end_time = benchmark_timer_read(); |
---|
116 | |
---|
117 | put_time( |
---|
118 | "rtems_message_queue_receive: not available NO_WAIT", |
---|
119 | end_time, |
---|
120 | operation_count, |
---|
121 | overhead, |
---|
122 | 0 |
---|
123 | ); |
---|
124 | |
---|
125 | } |
---|
126 | |
---|
127 | rtems_task High_task( |
---|
128 | rtems_task_argument argument |
---|
129 | ) |
---|
130 | { |
---|
131 | size_t size; |
---|
132 | |
---|
133 | benchmark_timer_initialize(); |
---|
134 | (void) rtems_message_queue_receive( |
---|
135 | Queue_id, |
---|
136 | (long (*)[4]) Buffer, |
---|
137 | &size, |
---|
138 | RTEMS_DEFAULT_OPTIONS, |
---|
139 | RTEMS_NO_TIMEOUT |
---|
140 | ); |
---|
141 | } |
---|
142 | |
---|
143 | rtems_task Middle_tasks( |
---|
144 | rtems_task_argument argument |
---|
145 | ) |
---|
146 | { |
---|
147 | size_t size; |
---|
148 | |
---|
149 | (void) rtems_message_queue_receive( |
---|
150 | Queue_id, |
---|
151 | (long (*)[4]) Buffer, |
---|
152 | &size, |
---|
153 | RTEMS_DEFAULT_OPTIONS, |
---|
154 | RTEMS_NO_TIMEOUT |
---|
155 | ); |
---|
156 | } |
---|
157 | |
---|
158 | |
---|
159 | rtems_task Low_task( |
---|
160 | rtems_task_argument argument |
---|
161 | ) |
---|
162 | { |
---|
163 | end_time = benchmark_timer_read(); |
---|
164 | |
---|
165 | put_time( |
---|
166 | "rtems_message_queue_receive: not available caller blocks", |
---|
167 | end_time, |
---|
168 | operation_count - 1, |
---|
169 | 0, |
---|
170 | 0 |
---|
171 | ); |
---|
172 | |
---|
173 | TEST_END(); |
---|
174 | rtems_test_exit( 0 ); |
---|
175 | } |
---|