source: rtems/testsuites/tmtests/tm22/task1.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

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