source: rtems/testsuites/tmtests/tm22/task1.c @ 4b374f36

4.104.114.84.95
Last change on this file since 4b374f36 was 4b374f36, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 17, 1995 at 7:36:43 PM

maximum number of messages removed and include statement cleanup

  • Property mode set to 100644
File size: 4.1 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 *  task1.c,v 1.2 1995/05/31 17:18:40 joel Exp
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
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  puts( "\n\n*** TIME TEST 22 ***" );
44
45  status = rtems_message_queue_create(
46    rtems_build_name( 'M', 'Q', '1', ' '),
47    100,
48    16,
49    RTEMS_DEFAULT_ATTRIBUTES,
50    &Queue_id
51  );
52  directive_failed( status, "rtems_message_queue_create" );
53
54  status = rtems_task_create(
55    rtems_build_name( 'L', 'O', 'W', ' ' ),
56    10,
57    2048,
58    RTEMS_NO_PREEMPT,
59    RTEMS_DEFAULT_ATTRIBUTES,
60    &id
61  );
62  directive_failed( status, "rtems_task_create" );
63
64  status = rtems_task_start( id, Low_task, 0 );
65  directive_failed( status, "rtems_task_start LOW" );
66
67  status = rtems_task_create(
68    1,
69    11,
70    1024,
71    RTEMS_DEFAULT_MODES,
72    RTEMS_DEFAULT_ATTRIBUTES,
73    &id
74  );
75  directive_failed( status, "rtems_task_create RTEMS_PREEMPT" );
76
77  status = rtems_task_start( id, Preempt_task, 0 );
78  directive_failed( status, "rtems_task_start RTEMS_PREEMPT" );
79
80  status = rtems_task_delete( RTEMS_SELF );
81  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
82}
83
84rtems_task High_task(
85  rtems_task_argument argument
86)
87{
88  rtems_unsigned32  count;
89  rtems_status_code status;
90
91  Timer_initialize();
92    (void) rtems_message_queue_broadcast(
93             Queue_id,
94             (long (*)[4]) Buffer,
95             16,
96             &count
97           );
98  end_time = Read_timer();
99
100  put_time(
101    "rtems_message_queue_broadcast (readying)",
102    end_time,
103    1,
104    0,
105    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
106  );
107
108  status = rtems_task_suspend(RTEMS_SELF);
109  directive_failed( status, "rtems_task_suspend" );
110}
111
112rtems_task Low_task(
113  rtems_task_argument argument
114)
115{
116  rtems_id          id;
117  rtems_unsigned32  index;
118  rtems_unsigned32  count;
119  rtems_unsigned32  size;
120  rtems_status_code status;
121
122  status = rtems_task_create(
123    rtems_build_name( 'H', 'I', 'G', 'H' ),
124    5,
125    2048,
126    RTEMS_NO_PREEMPT,
127    RTEMS_DEFAULT_ATTRIBUTES,
128    &id
129  );
130  directive_failed( status, "rtems_task_create" );
131
132  status = rtems_task_start( id, High_task, 0 );
133  directive_failed( status, "rtems_task_start HIGH" );
134
135  status = rtems_message_queue_receive(
136    Queue_id,
137    (long (*)[4]) Buffer,
138    &size,
139    RTEMS_DEFAULT_OPTIONS,
140    RTEMS_NO_TIMEOUT
141  );
142  directive_failed( status, "message_queu_receive" );
143
144  Timer_initialize();
145    for ( index=1 ; index <= OPERATION_COUNT ; index++ )
146      (void) rtems_message_queue_broadcast(
147               Queue_id,
148               (long (*)[4]) Buffer,
149               16,
150               &count
151             );
152  end_time = Read_timer();
153
154  put_time(
155    "rtems_message_queue_broadcast (no waiting tasks)",
156    end_time,
157    OPERATION_COUNT,
158    1,
159    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
160  );
161
162  (void) rtems_message_queue_receive(
163           Queue_id,
164           (long (*)[4]) Buffer,
165           &size,
166           RTEMS_DEFAULT_OPTIONS,
167           RTEMS_NO_TIMEOUT
168         );
169
170  /* should go to Preempt_task here */
171
172  end_time = Read_timer();
173
174  put_time(
175    "rtems_message_queue_broadcast (preempt)",
176    end_time,
177    1,
178    0,
179    CALLING_OVERHEAD_MESSAGE_QUEUE_BROADCAST
180  );
181
182  exit( 0 );
183}
184
185rtems_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}
Note: See TracBrowser for help on using the repository browser.