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 | |
---|
20 | rtems_id Queue_id; |
---|
21 | |
---|
22 | long Buffer[4]; |
---|
23 | |
---|
24 | rtems_task Low_task( |
---|
25 | rtems_task_argument argument |
---|
26 | ); |
---|
27 | |
---|
28 | rtems_task High_task( |
---|
29 | rtems_task_argument argument |
---|
30 | ); |
---|
31 | |
---|
32 | rtems_task Preempt_task( |
---|
33 | rtems_task_argument argument |
---|
34 | ); |
---|
35 | |
---|
36 | rtems_task Init( |
---|
37 | rtems_task_argument argument |
---|
38 | ) |
---|
39 | { |
---|
40 | rtems_id id; |
---|
41 | rtems_status_code status; |
---|
42 | |
---|
43 | puts( "\n\n*** TIME TEST 22 ***" ); |
---|
44 | |
---|
45 | status = rtems_message_queue_create( |
---|
46 | rtems_build_name( 'M', 'Q', '1', ' '), |
---|
47 | 0, |
---|
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 | 2048, |
---|
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 | 1024, |
---|
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 | &count |
---|
95 | ); |
---|
96 | end_time = Read_timer(); |
---|
97 | |
---|
98 | put_time( |
---|
99 | "rtems_message_queue_broadcast (readying)", |
---|
100 | end_time, |
---|
101 | 1, |
---|
102 | 0, |
---|
103 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
104 | ); |
---|
105 | |
---|
106 | status = rtems_task_suspend(RTEMS_SELF); |
---|
107 | directive_failed( status, "rtems_task_suspend" ); |
---|
108 | } |
---|
109 | |
---|
110 | rtems_task Low_task( |
---|
111 | rtems_task_argument argument |
---|
112 | ) |
---|
113 | { |
---|
114 | rtems_id id; |
---|
115 | rtems_unsigned32 index; |
---|
116 | rtems_unsigned32 count; |
---|
117 | rtems_status_code status; |
---|
118 | |
---|
119 | status = rtems_task_create( |
---|
120 | rtems_build_name( 'H', 'I', 'G', 'H' ), |
---|
121 | 5, |
---|
122 | 2048, |
---|
123 | RTEMS_NO_PREEMPT, |
---|
124 | RTEMS_DEFAULT_ATTRIBUTES, |
---|
125 | &id |
---|
126 | ); |
---|
127 | directive_failed( status, "rtems_task_create" ); |
---|
128 | |
---|
129 | status = rtems_task_start( id, High_task, 0 ); |
---|
130 | directive_failed( status, "rtems_task_start HIGH" ); |
---|
131 | |
---|
132 | status = rtems_message_queue_receive( |
---|
133 | Queue_id, |
---|
134 | (long (*)[4]) Buffer, |
---|
135 | RTEMS_DEFAULT_OPTIONS, |
---|
136 | RTEMS_NO_TIMEOUT |
---|
137 | ); |
---|
138 | directive_failed( status, "message_queu_receive" ); |
---|
139 | |
---|
140 | Timer_initialize(); |
---|
141 | for ( index=1 ; index <= OPERATION_COUNT ; index++ ) |
---|
142 | (void) rtems_message_queue_broadcast( |
---|
143 | Queue_id, |
---|
144 | (long (*)[4]) Buffer, |
---|
145 | &count |
---|
146 | ); |
---|
147 | end_time = Read_timer(); |
---|
148 | |
---|
149 | put_time( |
---|
150 | "rtems_message_queue_broadcast (no waiting tasks)", |
---|
151 | end_time, |
---|
152 | OPERATION_COUNT, |
---|
153 | 1, |
---|
154 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
155 | ); |
---|
156 | |
---|
157 | (void) rtems_message_queue_receive( |
---|
158 | Queue_id, |
---|
159 | (long (*)[4]) Buffer, |
---|
160 | RTEMS_DEFAULT_OPTIONS, |
---|
161 | RTEMS_NO_TIMEOUT |
---|
162 | ); |
---|
163 | |
---|
164 | /* should go to Preempt_task here */ |
---|
165 | |
---|
166 | end_time = Read_timer(); |
---|
167 | |
---|
168 | put_time( |
---|
169 | "rtems_message_queue_broadcast (preempt)", |
---|
170 | end_time, |
---|
171 | 1, |
---|
172 | 0, |
---|
173 | CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST |
---|
174 | ); |
---|
175 | |
---|
176 | exit( 0 ); |
---|
177 | } |
---|
178 | |
---|
179 | rtems_task Preempt_task( |
---|
180 | rtems_task_argument argument |
---|
181 | ) |
---|
182 | { |
---|
183 | rtems_unsigned32 count; |
---|
184 | |
---|
185 | Timer_initialize(); |
---|
186 | (void) rtems_message_queue_broadcast( |
---|
187 | Queue_id, |
---|
188 | (long (*)[4]) Buffer, |
---|
189 | &count |
---|
190 | ); |
---|
191 | |
---|
192 | /* should be preempted by low task */ |
---|
193 | } |
---|