source: rtems/c/src/tests/tmtests/tm09/task1.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 5.2 KB
Line 
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#include "system.h"
15#undef EXTERN
16#define EXTERN
17#include "conftbl.h"
18#include "gvar.h"
19
20rtems_id Queue_id;
21
22rtems_task Test_task(
23  rtems_task_argument argument
24);
25void queue_test();
26
27rtems_task Init(
28  rtems_task_argument argument
29)
30{
31  rtems_status_code status;
32
33  puts( "\n\n*** TIME TEST 9 ***" );
34
35  status = rtems_task_create(
36    1,
37    128,
38    4096,
39    RTEMS_DEFAULT_MODES,
40    RTEMS_DEFAULT_ATTRIBUTES,
41    &Task_id[ 1 ]
42  );
43  directive_failed( status, "rtems_task_create" );
44
45  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
46  directive_failed( status, "rtems_task_start" );
47
48  status = rtems_task_delete( RTEMS_SELF );
49  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
50}
51
52rtems_task Test_task (
53  rtems_task_argument argument
54)
55{
56  Timer_initialize();
57    rtems_message_queue_create(
58      1,
59      OPERATION_COUNT,
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  exit( 0 );
88}
89
90void queue_test()
91{
92  rtems_unsigned32  send_loop_time;
93  rtems_unsigned32  urgent_loop_time;
94  rtems_unsigned32  receive_loop_time;
95  rtems_unsigned32  send_time;
96  rtems_unsigned32  urgent_time;
97  rtems_unsigned32  receive_time;
98  rtems_unsigned32  empty_flush_time;
99  rtems_unsigned32  flush_time;
100  rtems_unsigned32  empty_flush_count;
101  rtems_unsigned32  flush_count;
102  rtems_unsigned32  index;
103  rtems_unsigned32  iterations;
104  long              buffer[4];
105  rtems_status_code status;
106
107  send_loop_time    = 0;
108  urgent_loop_time  = 0;
109  receive_loop_time = 0;
110  send_time         = 0;
111  urgent_time       = 0;
112  receive_time      = 0;
113  empty_flush_time  = 0;
114  flush_time        = 0;
115  flush_count       = 0;
116  empty_flush_count = 0;
117
118  for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) {
119
120    Timer_initialize();
121      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
122        (void) Empty_function();
123    send_loop_time += Read_timer();
124
125    Timer_initialize();
126      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
127        (void) Empty_function();
128    urgent_loop_time += Read_timer();
129
130    Timer_initialize();
131      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
132        (void) Empty_function();
133    receive_loop_time += Read_timer();
134
135    Timer_initialize();
136      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
137        (void) rtems_message_queue_send( Queue_id, (long (*)[4])buffer );
138    send_time += Read_timer();
139
140    Timer_initialize();
141      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
142        (void) rtems_message_queue_receive(
143                 Queue_id,
144                 (long (*)[4])buffer,
145                 RTEMS_DEFAULT_OPTIONS,
146                 RTEMS_NO_TIMEOUT
147               );
148    receive_time += Read_timer();
149
150    Timer_initialize();
151      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
152        (void) rtems_message_queue_urgent( Queue_id, (long (*)[4])buffer );
153    urgent_time += Read_timer();
154
155    Timer_initialize();
156      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
157        (void) rtems_message_queue_receive(
158                 Queue_id,
159                 (long (*)[4])buffer,
160                 RTEMS_DEFAULT_OPTIONS,
161                 RTEMS_NO_TIMEOUT
162               );
163    receive_time += Read_timer();
164
165    Timer_initialize();
166      rtems_message_queue_flush( Queue_id, &empty_flush_count );
167    empty_flush_time += Read_timer();
168
169    /* send one message to flush */
170    status = rtems_message_queue_send(
171       Queue_id,
172       (long (*)[4])buffer
173    );
174    directive_failed( status, "rtems_message_queue_send" );
175
176    Timer_initialize();
177      rtems_message_queue_flush( Queue_id, &flush_count );
178    flush_time += Read_timer();
179  }
180
181  put_time(
182    "rtems_message_queue_send (no tasks waiting)",
183    send_time,
184    OPERATION_COUNT * OPERATION_COUNT,
185    send_loop_time,
186    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
187  );
188
189  put_time(
190    "rtems_message_queue_urgent (no tasks waiting)",
191    urgent_time,
192    OPERATION_COUNT * OPERATION_COUNT,
193    urgent_loop_time,
194    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
195  );
196
197  put_time(
198    "rtems_message_queue_receive (messages available)",
199    receive_time,
200    OPERATION_COUNT * OPERATION_COUNT * 2,
201    receive_loop_time * 2,
202    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
203  );
204
205  put_time(
206    "rtems_message_queue_flush (empty queue)",
207    empty_flush_time,
208    OPERATION_COUNT,
209    0,
210    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
211  );
212
213  put_time(
214    "rtems_message_queue_flush (messages flushed)",
215    flush_time,
216    OPERATION_COUNT,
217    0,
218    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
219  );
220
221}
Note: See TracBrowser for help on using the repository browser.