1 | /* |
---|
2 | * |
---|
3 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
4 | * On-Line Applications Research Corporation (OAR). |
---|
5 | * All rights assigned to U.S. Government, 1994. |
---|
6 | * |
---|
7 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
8 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
9 | * notice must appear in all copies of this file and its derivatives. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #define TEST_INIT |
---|
15 | #include "system.h" |
---|
16 | |
---|
17 | rtems_id Queue_id; |
---|
18 | |
---|
19 | rtems_task Test_task( |
---|
20 | rtems_task_argument argument |
---|
21 | ); |
---|
22 | void queue_test(); |
---|
23 | |
---|
24 | rtems_task Init( |
---|
25 | rtems_task_argument argument |
---|
26 | ) |
---|
27 | { |
---|
28 | rtems_status_code status; |
---|
29 | |
---|
30 | Print_Warning(); |
---|
31 | |
---|
32 | puts( "\n\n*** TIME TEST 9 ***" ); |
---|
33 | |
---|
34 | status = rtems_task_create( |
---|
35 | 1, |
---|
36 | 128, |
---|
37 | RTEMS_MINIMUM_STACK_SIZE, |
---|
38 | RTEMS_DEFAULT_MODES, |
---|
39 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
40 | &Task_id[ 1 ] |
---|
41 | ); |
---|
42 | directive_failed( status, "rtems_task_create" ); |
---|
43 | |
---|
44 | status = rtems_task_start( Task_id[ 1 ], Test_task, 0 ); |
---|
45 | directive_failed( status, "rtems_task_start" ); |
---|
46 | |
---|
47 | status = rtems_task_delete( RTEMS_SELF ); |
---|
48 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
49 | } |
---|
50 | |
---|
51 | rtems_task Test_task ( |
---|
52 | rtems_task_argument argument |
---|
53 | ) |
---|
54 | { |
---|
55 | Timer_initialize(); |
---|
56 | rtems_message_queue_create( |
---|
57 | 1, |
---|
58 | OPERATION_COUNT, |
---|
59 | 16, |
---|
60 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
61 | &Queue_id |
---|
62 | ); |
---|
63 | end_time = Read_timer(); |
---|
64 | |
---|
65 | put_time( |
---|
66 | "rtems_message_queue_create", |
---|
67 | end_time, |
---|
68 | 1, |
---|
69 | 0, |
---|
70 | CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE |
---|
71 | ); |
---|
72 | |
---|
73 | queue_test(); |
---|
74 | |
---|
75 | Timer_initialize(); |
---|
76 | rtems_message_queue_delete( Queue_id ); |
---|
77 | end_time = Read_timer(); |
---|
78 | |
---|
79 | put_time( |
---|
80 | "rtems_message_queue_delete", |
---|
81 | end_time, |
---|
82 | 1, |
---|
83 | 0, |
---|
84 | CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE |
---|
85 | ); |
---|
86 | |
---|
87 | puts( "*** END OF TEST 9 ***" ); |
---|
88 | exit( 0 ); |
---|
89 | } |
---|
90 | |
---|
91 | void queue_test() |
---|
92 | { |
---|
93 | rtems_unsigned32 send_loop_time; |
---|
94 | rtems_unsigned32 urgent_loop_time; |
---|
95 | rtems_unsigned32 receive_loop_time; |
---|
96 | rtems_unsigned32 send_time; |
---|
97 | rtems_unsigned32 urgent_time; |
---|
98 | rtems_unsigned32 receive_time; |
---|
99 | rtems_unsigned32 empty_flush_time; |
---|
100 | rtems_unsigned32 flush_time; |
---|
101 | rtems_unsigned32 empty_flush_count; |
---|
102 | rtems_unsigned32 flush_count; |
---|
103 | rtems_unsigned32 index; |
---|
104 | rtems_unsigned32 iterations; |
---|
105 | long buffer[4]; |
---|
106 | rtems_status_code status; |
---|
107 | rtems_unsigned32 size; |
---|
108 | |
---|
109 | send_loop_time = 0; |
---|
110 | urgent_loop_time = 0; |
---|
111 | receive_loop_time = 0; |
---|
112 | send_time = 0; |
---|
113 | urgent_time = 0; |
---|
114 | receive_time = 0; |
---|
115 | empty_flush_time = 0; |
---|
116 | flush_time = 0; |
---|
117 | flush_count = 0; |
---|
118 | empty_flush_count = 0; |
---|
119 | |
---|
120 | for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) { |
---|
121 | |
---|
122 | Timer_initialize(); |
---|
123 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
124 | (void) Empty_function(); |
---|
125 | send_loop_time += Read_timer(); |
---|
126 | |
---|
127 | Timer_initialize(); |
---|
128 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
129 | (void) Empty_function(); |
---|
130 | urgent_loop_time += Read_timer(); |
---|
131 | |
---|
132 | Timer_initialize(); |
---|
133 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
134 | (void) Empty_function(); |
---|
135 | receive_loop_time += Read_timer(); |
---|
136 | |
---|
137 | Timer_initialize(); |
---|
138 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
139 | (void) rtems_message_queue_send( Queue_id, (long (*)[4])buffer, 16 ); |
---|
140 | send_time += Read_timer(); |
---|
141 | |
---|
142 | Timer_initialize(); |
---|
143 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
144 | (void) rtems_message_queue_receive( |
---|
145 | Queue_id, |
---|
146 | (long (*)[4])buffer, |
---|
147 | &size, |
---|
148 | RTEMS_DEFAULT_OPTIONS, |
---|
149 | RTEMS_NO_TIMEOUT |
---|
150 | ); |
---|
151 | receive_time += Read_timer(); |
---|
152 | |
---|
153 | Timer_initialize(); |
---|
154 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
155 | (void) rtems_message_queue_urgent( Queue_id, (long (*)[4])buffer, 16 ); |
---|
156 | urgent_time += Read_timer(); |
---|
157 | |
---|
158 | Timer_initialize(); |
---|
159 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
160 | (void) rtems_message_queue_receive( |
---|
161 | Queue_id, |
---|
162 | (long (*)[4])buffer, |
---|
163 | &size, |
---|
164 | RTEMS_DEFAULT_OPTIONS, |
---|
165 | RTEMS_NO_TIMEOUT |
---|
166 | ); |
---|
167 | receive_time += Read_timer(); |
---|
168 | |
---|
169 | Timer_initialize(); |
---|
170 | rtems_message_queue_flush( Queue_id, &empty_flush_count ); |
---|
171 | empty_flush_time += Read_timer(); |
---|
172 | |
---|
173 | /* send one message to flush */ |
---|
174 | status = rtems_message_queue_send( |
---|
175 | Queue_id, |
---|
176 | (long (*)[4])buffer, |
---|
177 | 16 |
---|
178 | ); |
---|
179 | directive_failed( status, "rtems_message_queue_send" ); |
---|
180 | |
---|
181 | Timer_initialize(); |
---|
182 | rtems_message_queue_flush( Queue_id, &flush_count ); |
---|
183 | flush_time += Read_timer(); |
---|
184 | } |
---|
185 | |
---|
186 | put_time( |
---|
187 | "rtems_message_queue_send: no waiting tasks", |
---|
188 | send_time, |
---|
189 | OPERATION_COUNT * OPERATION_COUNT, |
---|
190 | send_loop_time, |
---|
191 | CALLING_OVERHEAD_MESSAGE_QUEUE_SEND |
---|
192 | ); |
---|
193 | |
---|
194 | put_time( |
---|
195 | "rtems_message_queue_urgent: no waiting tasks", |
---|
196 | urgent_time, |
---|
197 | OPERATION_COUNT * OPERATION_COUNT, |
---|
198 | urgent_loop_time, |
---|
199 | CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT |
---|
200 | ); |
---|
201 | |
---|
202 | put_time( |
---|
203 | "rtems_message_queue_receive: available", |
---|
204 | receive_time, |
---|
205 | OPERATION_COUNT * OPERATION_COUNT * 2, |
---|
206 | receive_loop_time * 2, |
---|
207 | CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE |
---|
208 | ); |
---|
209 | |
---|
210 | put_time( |
---|
211 | "rtems_message_queue_flush: no messages flushed", |
---|
212 | empty_flush_time, |
---|
213 | OPERATION_COUNT, |
---|
214 | 0, |
---|
215 | CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH |
---|
216 | ); |
---|
217 | |
---|
218 | put_time( |
---|
219 | "rtems_message_queue_flush: messages flushed", |
---|
220 | flush_time, |
---|
221 | OPERATION_COUNT, |
---|
222 | 0, |
---|
223 | CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH |
---|
224 | ); |
---|
225 | |
---|
226 | } |
---|