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