source: rtems/testsuites/tmtests/tm22/task1.c @ 183af89

4.115
Last change on this file since 183af89 was a4bc4d6e, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/22/11 at 10:00:39

Add HAVE_CONFIG_H.

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 *
3 *  COPYRIGHT (c) 1989-2007.
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#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#define CONFIGURE_INIT
18#include "system.h"
19
20rtems_id Queue_id;
21
22long Buffer[4];
23
24rtems_task Low_task(
25  rtems_task_argument argument
26);
27
28rtems_task High_task(
29  rtems_task_argument argument
30);
31
32rtems_task Preempt_task(
33  rtems_task_argument argument
34);
35
36rtems_task Init(
37  rtems_task_argument argument
38)
39{
40  rtems_id          id;
41  rtems_status_code status;
42
43  Print_Warning();
44
45  puts( "\n\n*** TIME TEST 22 ***" );
46
47  status = rtems_message_queue_create(
48    rtems_build_name( 'M', 'Q', '1', ' '),
49    100,
50    MESSAGE_SIZE,
51    RTEMS_DEFAULT_ATTRIBUTES,
52    &Queue_id
53  );
54  directive_failed( status, "rtems_message_queue_create" );
55
56  status = rtems_task_create(
57    rtems_build_name( 'L', 'O', 'W', ' ' ),
58    10,
59    RTEMS_MINIMUM_STACK_SIZE,
60    RTEMS_NO_PREEMPT,
61    RTEMS_DEFAULT_ATTRIBUTES,
62    &id
63  );
64  directive_failed( status, "rtems_task_create" );
65
66  status = rtems_task_start( id, Low_task, 0 );
67  directive_failed( status, "rtems_task_start LOW" );
68
69  status = rtems_task_create(
70    1,
71    11,
72    RTEMS_MINIMUM_STACK_SIZE,
73    RTEMS_DEFAULT_MODES,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    &id
76  );
77  directive_failed( status, "rtems_task_create RTEMS_PREEMPT" );
78
79  status = rtems_task_start( id, Preempt_task, 0 );
80  directive_failed( status, "rtems_task_start RTEMS_PREEMPT" );
81
82  status = rtems_task_delete( RTEMS_SELF );
83  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
84}
85
86rtems_task High_task(
87  rtems_task_argument argument
88)
89{
90  uint32_t    count;
91  rtems_status_code status;
92
93  benchmark_timer_initialize();
94    (void) rtems_message_queue_broadcast(
95             Queue_id,
96             Buffer,
97             MESSAGE_SIZE,
98             &count
99           );
100  end_time = benchmark_timer_read();
101
102  put_time(
103    "rtems_message_queue_broadcast: task readied -- returns to caller",
104    end_time,
105    1,
106    0,
107    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
108  );
109
110  status = rtems_task_suspend(RTEMS_SELF);
111  directive_failed( status, "rtems_task_suspend" );
112}
113
114rtems_task Low_task(
115  rtems_task_argument argument
116)
117{
118  rtems_id          id;
119  uint32_t          index;
120  uint32_t          count;
121  size_t            size;
122  rtems_status_code status;
123
124  status = rtems_task_create(
125    rtems_build_name( 'H', 'I', 'G', 'H' ),
126    5,
127    RTEMS_MINIMUM_STACK_SIZE,
128    RTEMS_NO_PREEMPT,
129    RTEMS_DEFAULT_ATTRIBUTES,
130    &id
131  );
132  directive_failed( status, "rtems_task_create" );
133
134  status = rtems_task_start( id, High_task, 0 );
135  directive_failed( status, "rtems_task_start HIGH" );
136
137  status = rtems_message_queue_receive(
138    Queue_id,
139    (long (*)[4]) Buffer,
140    &size,
141    RTEMS_DEFAULT_OPTIONS,
142    RTEMS_NO_TIMEOUT
143  );
144  directive_failed( status, "message_queu_receive" );
145
146  benchmark_timer_initialize();
147    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
148      (void) rtems_message_queue_broadcast(
149               Queue_id,
150               Buffer,
151               MESSAGE_SIZE,
152               &count
153             );
154  end_time = benchmark_timer_read();
155
156  put_time(
157    "rtems_message_queue_broadcast: no waiting tasks",
158    end_time,
159    OPERATION_COUNT,
160    1,
161    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
162  );
163
164  (void) rtems_message_queue_receive(
165           Queue_id,
166           (long (*)[4]) Buffer,
167           &size,
168           RTEMS_DEFAULT_OPTIONS,
169           RTEMS_NO_TIMEOUT
170         );
171
172  /* should go to Preempt_task here */
173
174  end_time = benchmark_timer_read();
175
176  put_time(
177    "rtems_message_queue_broadcast: task readied -- preempts caller",
178    end_time,
179    1,
180    0,
181    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
182  );
183
184  puts( "*** END OF TEST 22 ***" );
185  rtems_test_exit( 0 );
186}
187
188rtems_task Preempt_task(
189  rtems_task_argument argument
190)
191{
192  uint32_t    count;
193
194  benchmark_timer_initialize();
195    (void) rtems_message_queue_broadcast(
196             Queue_id,
197             Buffer,
198             MESSAGE_SIZE,
199             &count
200           );
201
202 /* should be preempted by low task */
203}
Note: See TracBrowser for help on using the repository browser.