source: rtems/testsuites/tmtests/tm09/task1.c @ 6c0301d

4.115
Last change on this file since 6c0301d was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 5.5 KB
Line 
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#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17rtems_id Queue_id;
18
19rtems_task Test_task(
20  rtems_task_argument argument
21);
22void queue_test(void);
23
24rtems_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    (RTEMS_MAXIMUM_PRIORITY / 2u) + 1u,
37    RTEMS_MINIMUM_STACK_SIZE * 2,
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
51rtems_task Test_task (
52  rtems_task_argument argument
53)
54{
55  benchmark_timer_initialize();
56    rtems_message_queue_create(
57      1,
58      OPERATION_COUNT,
59      MESSAGE_SIZE,
60      RTEMS_DEFAULT_ATTRIBUTES,
61      &Queue_id
62    );
63  end_time = benchmark_timer_read();
64
65  put_time(
66    "rtems_message_queue_create: only case",
67    end_time,
68    1,
69    0,
70    CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE
71  );
72
73  queue_test();
74
75  benchmark_timer_initialize();
76    rtems_message_queue_delete( Queue_id );
77  end_time = benchmark_timer_read();
78
79  put_time(
80    "rtems_message_queue_delete: only case",
81    end_time,
82    1,
83    0,
84    CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE
85  );
86
87  puts( "*** END OF TEST 9 ***" );
88  rtems_test_exit( 0 );
89}
90
91void queue_test(void)
92{
93  uint32_t    send_loop_time;
94  uint32_t    urgent_loop_time;
95  uint32_t    receive_loop_time;
96  uint32_t    send_time;
97  uint32_t    urgent_time;
98  uint32_t    receive_time;
99  uint32_t    empty_flush_time;
100  uint32_t    flush_time;
101  uint32_t    empty_flush_count;
102  uint32_t    flush_count;
103  uint32_t    index;
104  uint32_t    iterations;
105  long        buffer[4];
106  rtems_status_code status;
107  size_t      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    benchmark_timer_initialize();
123      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
124        (void) benchmark_timer_empty_function();
125    send_loop_time += benchmark_timer_read();
126
127    benchmark_timer_initialize();
128      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
129        (void) benchmark_timer_empty_function();
130    urgent_loop_time += benchmark_timer_read();
131
132    benchmark_timer_initialize();
133      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
134        (void) benchmark_timer_empty_function();
135    receive_loop_time += benchmark_timer_read();
136
137    benchmark_timer_initialize();
138      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
139        (void) rtems_message_queue_send( Queue_id, buffer, MESSAGE_SIZE );
140    send_time += benchmark_timer_read();
141
142    benchmark_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 += benchmark_timer_read();
152
153    benchmark_timer_initialize();
154      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
155        (void) rtems_message_queue_urgent( Queue_id, buffer, MESSAGE_SIZE );
156    urgent_time += benchmark_timer_read();
157
158    benchmark_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 += benchmark_timer_read();
168
169    benchmark_timer_initialize();
170      rtems_message_queue_flush( Queue_id, &empty_flush_count );
171    empty_flush_time += benchmark_timer_read();
172
173    /* send one message to flush */
174    status = rtems_message_queue_send(
175       Queue_id,
176       (long (*)[4])buffer,
177       MESSAGE_SIZE
178    );
179    directive_failed( status, "rtems_message_queue_send" );
180
181    benchmark_timer_initialize();
182      rtems_message_queue_flush( Queue_id, &flush_count );
183    flush_time += benchmark_timer_read();
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}
Note: See TracBrowser for help on using the repository browser.