source: rtems/testsuites/tmtests/tm09/task1.c @ 95a81ab

4.104.114.84.95
Last change on this file since 95a81ab was 95a81ab, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:53:55

2003-09-04 Joel Sherrill <joel@…>

  • include/timesys.h, tm01/system.h, tm01/task1.c, tm01/tm01.doc, tm02/system.h, tm02/task1.c, tm02/tm02.doc, tm03/system.h, tm03/task1.c, tm03/tm03.doc, tm04/system.h, tm04/task1.c, tm04/tm04.doc, tm05/system.h, tm05/task1.c, tm05/tm05.doc, tm06/system.h, tm06/task1.c, tm06/tm06.doc, tm07/system.h, tm07/task1.c, tm07/tm07.doc, tm08/system.h, tm08/task1.c, tm08/tm08.doc, tm09/system.h, tm09/task1.c, tm09/tm09.doc, tm10/system.h, tm10/task1.c, tm10/tm10.doc, tm11/system.h, tm11/task1.c, tm11/tm11.doc, tm12/system.h, tm12/task1.c, tm12/tm12.doc, tm13/system.h, tm13/task1.c, tm13/tm13.doc, tm14/system.h, tm14/task1.c, tm14/tm14.doc, tm15/system.h, tm15/task1.c, tm15/tm15.doc, tm16/system.h, tm16/task1.c, tm16/tm16.doc, tm17/system.h, tm17/task1.c, tm17/tm17.doc, tm18/system.h, tm18/task1.c, tm18/tm18.doc, tm19/system.h, tm19/task1.c, tm19/tm19.doc, tm20/system.h, tm20/task1.c, tm20/tm20.doc, tm21/system.h, tm21/task1.c, tm21/tm21.doc, tm22/system.h, tm22/task1.c, tm22/tm22.doc, tm23/system.h, tm23/task1.c, tm23/tm23.doc, tm24/system.h, tm24/task1.c, tm24/tm24.doc, tm25/system.h, tm25/task1.c, tm25/tm25.doc, tm26/fptest.h, tm26/system.h, tm26/task1.c, tm26/tm26.doc, tm27/system.h, tm27/task1.c, tm27/tm27.doc, tm28/system.h, tm28/task1.c, tm28/tm28.doc, tm29/system.h, tm29/task1.c, tm29/tm29.doc, tmck/system.h, tmck/task1.c, tmck/tmck.doc, tmoverhd/dumrtems.h, tmoverhd/empty.c, tmoverhd/system.h, tmoverhd/testtask.c, tmoverhd/tmoverhd.doc: URL for license changed.
  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-1999.
4 *  On-Line Applications Research Corporation (OAR).
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  $Id$
11 */
12
13#define TEST_INIT
14#include "system.h"
15
16rtems_id Queue_id;
17
18rtems_task Test_task(
19  rtems_task_argument argument
20);
21void queue_test();
22
23rtems_task Init(
24  rtems_task_argument argument
25)
26{
27  rtems_status_code status;
28
29  Print_Warning();
30
31  puts( "\n\n*** TIME TEST 9 ***" );
32
33  status = rtems_task_create(
34    1,
35    128,
36    RTEMS_MINIMUM_STACK_SIZE * 2,
37    RTEMS_DEFAULT_MODES,
38    RTEMS_DEFAULT_ATTRIBUTES,
39    &Task_id[ 1 ]
40  );
41  directive_failed( status, "rtems_task_create" );
42
43  status = rtems_task_start( Task_id[ 1 ], Test_task, 0 );
44  directive_failed( status, "rtems_task_start" );
45
46  status = rtems_task_delete( RTEMS_SELF );
47  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
48}
49
50#define MESSAGE_SIZE (sizeof(long) * 4)
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      MESSAGE_SIZE,
61      RTEMS_DEFAULT_ATTRIBUTES,
62      &Queue_id
63    );
64  end_time = Read_timer();
65
66  put_time(
67    "rtems_message_queue_create",
68    end_time,
69    1,
70    0,
71    CALLING_OVERHEAD_MESSAGE_QUEUE_CREATE
72  );
73
74  queue_test();
75
76  Timer_initialize();
77    rtems_message_queue_delete( Queue_id );
78  end_time = Read_timer();
79
80  put_time(
81    "rtems_message_queue_delete",
82    end_time,
83    1,
84    0,
85    CALLING_OVERHEAD_MESSAGE_QUEUE_DELETE
86  );
87
88  puts( "*** END OF TEST 9 ***" );
89  rtems_test_exit( 0 );
90}
91
92void queue_test()
93{
94  rtems_unsigned32  send_loop_time;
95  rtems_unsigned32  urgent_loop_time;
96  rtems_unsigned32  receive_loop_time;
97  rtems_unsigned32  send_time;
98  rtems_unsigned32  urgent_time;
99  rtems_unsigned32  receive_time;
100  rtems_unsigned32  empty_flush_time;
101  rtems_unsigned32  flush_time;
102  rtems_unsigned32  empty_flush_count;
103  rtems_unsigned32  flush_count;
104  rtems_unsigned32  index;
105  rtems_unsigned32  iterations;
106  long              buffer[4];
107  rtems_status_code status;
108  rtems_unsigned32  size;
109
110  send_loop_time    = 0;
111  urgent_loop_time  = 0;
112  receive_loop_time = 0;
113  send_time         = 0;
114  urgent_time       = 0;
115  receive_time      = 0;
116  empty_flush_time  = 0;
117  flush_time        = 0;
118  flush_count       = 0;
119  empty_flush_count = 0;
120
121  for ( iterations = 1 ; iterations <= OPERATION_COUNT ; iterations++ ) {
122
123    Timer_initialize();
124      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
125        (void) Empty_function();
126    send_loop_time += Read_timer();
127
128    Timer_initialize();
129      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
130        (void) Empty_function();
131    urgent_loop_time += Read_timer();
132
133    Timer_initialize();
134      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
135        (void) Empty_function();
136    receive_loop_time += Read_timer();
137
138    Timer_initialize();
139      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
140        (void) rtems_message_queue_send( Queue_id, buffer, MESSAGE_SIZE );
141    send_time += Read_timer();
142
143    Timer_initialize();
144      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
145        (void) rtems_message_queue_receive(
146                 Queue_id,
147                 (long (*)[4])buffer,
148                 &size,
149                 RTEMS_DEFAULT_OPTIONS,
150                 RTEMS_NO_TIMEOUT
151               );
152    receive_time += Read_timer();
153
154    Timer_initialize();
155      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
156        (void) rtems_message_queue_urgent( Queue_id, buffer, MESSAGE_SIZE );
157    urgent_time += Read_timer();
158
159    Timer_initialize();
160      for ( index=1 ; index <= OPERATION_COUNT ; index++ )
161        (void) rtems_message_queue_receive(
162                 Queue_id,
163                 (long (*)[4])buffer,
164                 &size,
165                 RTEMS_DEFAULT_OPTIONS,
166                 RTEMS_NO_TIMEOUT
167               );
168    receive_time += Read_timer();
169
170    Timer_initialize();
171      rtems_message_queue_flush( Queue_id, &empty_flush_count );
172    empty_flush_time += Read_timer();
173
174    /* send one message to flush */
175    status = rtems_message_queue_send(
176       Queue_id,
177       (long (*)[4])buffer,
178       MESSAGE_SIZE
179    );
180    directive_failed( status, "rtems_message_queue_send" );
181
182    Timer_initialize();
183      rtems_message_queue_flush( Queue_id, &flush_count );
184    flush_time += Read_timer();
185  }
186
187  put_time(
188    "rtems_message_queue_send: no waiting tasks",
189    send_time,
190    OPERATION_COUNT * OPERATION_COUNT,
191    send_loop_time,
192    CALLING_OVERHEAD_MESSAGE_QUEUE_SEND
193  );
194
195  put_time(
196    "rtems_message_queue_urgent: no waiting tasks",
197    urgent_time,
198    OPERATION_COUNT * OPERATION_COUNT,
199    urgent_loop_time,
200    CALLING_OVERHEAD_MESSAGE_QUEUE_URGENT
201  );
202
203  put_time(
204    "rtems_message_queue_receive: available",
205    receive_time,
206    OPERATION_COUNT * OPERATION_COUNT * 2,
207    receive_loop_time * 2,
208    CALLING_OVERHEAD_MESSAGE_QUEUE_RECEIVE
209  );
210
211  put_time(
212    "rtems_message_queue_flush: no messages flushed",
213    empty_flush_time,
214    OPERATION_COUNT,
215    0,
216    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
217  );
218
219  put_time(
220    "rtems_message_queue_flush: messages flushed",
221    flush_time,
222    OPERATION_COUNT,
223    0,
224    CALLING_OVERHEAD_MESSAGE_QUEUE_FLUSH
225  );
226
227}
Note: See TracBrowser for help on using the repository browser.