source: rtems/testsuites/sptests/sp13/task1.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 11, 1995 at 7:35:39 PM

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 11.5 KB
Line 
1/*  Task_1
2 *
3 *  This routine serves as a test task.  It verifies the message manager.
4 *
5 *  Input parameters:
6 *    argument - task argument
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#include "system.h"
22#include <string.h>             /* for memcmp */
23
24extern rtems_configuration_table BSP_Configuration;
25
26char    big_send_buffer[2048];
27char    big_receive_buffer[2048];
28
29long    buffer[ 4 ];
30
31void dope_buffer(unsigned char *buff,
32                 int   buff_size,
33                 unsigned32 v)
34{
35    int i;
36    unsigned char ch;
37
38    ch = (' ' + (v % (0x7f - ' ')));
39   
40    for (i=0; i<buff_size; i++)
41    {
42        *buff++ = ch++;
43        if (ch >= 0x7f)
44            ch = ' ';
45    }
46}
47
48rtems_task Task_1(
49  rtems_task_argument argument
50)
51{
52  rtems_id          qid;
53  rtems_unsigned32  index;
54  rtems_unsigned32  count;
55  rtems_status_code status;
56  rtems_unsigned32  size;
57  rtems_unsigned32  queue_size;
58  char             *cp;
59 
60  status = rtems_message_queue_ident(
61    Queue_name[ 1 ],
62    RTEMS_SEARCH_ALL_NODES,
63    &qid
64  );
65  printf( "TA1 - rtems_message_queue_ident - qid => %08x\n", qid );
66  directive_failed( status, "rtems_message_queue_ident" );
67
68  Fill_buffer( "BUFFER 1 TO Q 1", buffer );
69  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 1" );
70  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, 16 );
71  directive_failed( status, "rtems_message_queue_send" );
72
73  Fill_buffer( "BUFFER 2 TO Q 1", buffer );
74  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 1" );
75  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, 16 );
76  directive_failed( status, "rtems_message_queue_send" );
77
78  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
79  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
80  directive_failed( status, "rtems_task_wake_after" );
81
82  Fill_buffer( "BUFFER 3 TO Q 1", buffer );
83  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 1" );
84  status = rtems_message_queue_send( Queue_id[ 1 ], buffer, 16 );
85  directive_failed( status, "rtems_message_queue_send" );
86
87  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
88  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
89  directive_failed( status, "rtems_task_wake_after" );
90
91pause();
92
93  Fill_buffer( "BUFFER 1 TO Q 2", buffer );
94  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 2" );
95  status = rtems_message_queue_send( Queue_id[ 2 ], buffer, 16 );
96  directive_failed( status, "rtems_message_queue_send" );
97
98  puts_nocr( "TA1 - rtems_message_queue_receive - receive from queue 1 - " );
99  puts     ( "10 second timeout" );
100  status = rtems_message_queue_receive(
101    Queue_id[ 1 ],
102    buffer,
103    &size,
104    RTEMS_DEFAULT_OPTIONS,
105    10 * TICKS_PER_SECOND
106  );
107  directive_failed( status, "rtems_message_queue_receive" );
108  puts_nocr( "TA1 - buffer received: " );
109  Put_buffer( buffer );
110  new_line;
111
112  puts( "TA1 - rtems_task_delete - delete TA2" );
113  status = rtems_task_delete( Task_id[ 2 ] );
114  directive_failed( status, "rtems_task_delete" );
115
116  Fill_buffer( "BUFFER 1 TO Q 3", buffer );
117  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 3" );
118  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
119  directive_failed( status, "rtems_message_queue_send" );
120
121  puts( "TA1 - rtems_task_wake_after - sleep 5 seconds" );
122  status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
123  directive_failed( status, "rtems_task_wake_after" );
124
125pause();
126
127  Fill_buffer( "BUFFER 2 TO Q 3", buffer );
128  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 3" );
129  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
130  directive_failed( status, "rtems_message_queue_send" );
131
132  Fill_buffer( "BUFFER 3 TO Q 3", buffer );
133  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 3" );
134  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
135  directive_failed( status, "rtems_message_queue_send" );
136
137  Fill_buffer( "BUFFER 4 TO Q 3", buffer );
138  puts( "TA1 - rtems_message_queue_send - BUFFER 4 TO Q 3" );
139  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
140  directive_failed( status, "rtems_message_queue_send" );
141
142  Fill_buffer( "BUFFER 5 TO Q 3", buffer );
143  puts( "TA1 - rtems_message_queue_urgent - BUFFER 5 TO Q 3" );
144  status = rtems_message_queue_urgent( Queue_id[ 3 ], buffer, 16 );
145  directive_failed( status, "rtems_message_queue_urgent" );
146
147  for ( index = 1 ; index <= 4 ; index++ ) {
148    puts(
149      "TA1 - rtems_message_queue_receive - receive from queue 3 - "
150        "RTEMS_WAIT FOREVER"
151    );
152    status = rtems_message_queue_receive(
153      Queue_id[ 3 ],
154      buffer,
155      &size,
156      RTEMS_DEFAULT_OPTIONS,
157      RTEMS_NO_TIMEOUT
158    );
159    directive_failed( status, "rtems_message_queue_receive" );
160    puts_nocr( "TA1 - buffer received: " );
161    Put_buffer( buffer );
162    new_line;
163  }
164
165  Fill_buffer( "BUFFER 3 TO Q 2", buffer );
166  puts( "TA1 - rtems_message_queue_urgent - BUFFER 3 TO Q 2" );
167  status = rtems_message_queue_urgent( Queue_id[ 2 ], buffer, 16 );
168  directive_failed( status, "rtems_message_queue_urgent" );
169
170  puts(
171    "TA1 - rtems_message_queue_receive - receive from queue 2 - "
172      "RTEMS_WAIT FOREVER"
173  );
174  status = rtems_message_queue_receive(
175    Queue_id[ 2 ],
176    buffer,
177    &size,
178    RTEMS_DEFAULT_OPTIONS,
179    RTEMS_NO_TIMEOUT
180  );
181  directive_failed( status, "rtems_message_queue_receive" );
182  puts_nocr( "TA1 - buffer received: " );
183  Put_buffer( buffer );
184  new_line;
185
186pause();
187
188  puts( "TA1 - rtems_message_queue_delete - delete queue 1" );
189  status = rtems_message_queue_delete( Queue_id[ 1 ] );
190  directive_failed( status, "rtems_message_queue_delete" );
191
192  Fill_buffer( "BUFFER 3 TO Q 2", buffer );
193  puts( "TA1 - rtems_message_queue_urgent - BUFFER 3 TO Q 2" );
194  status = rtems_message_queue_urgent( Queue_id[ 2 ], buffer, 16 );
195  directive_failed( status, "rtems_message_queue_urgent" );
196
197  puts( "TA1 - rtems_message_queue_delete - delete queue 2" );
198  status = rtems_message_queue_delete( Queue_id[ 2 ] );
199  directive_failed( status, "rtems_message_queue_delete" );
200
201  puts( "TA1 - rtems_message_queue_flush - empty Q 3" );
202  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
203  printf( "TA1 - %d messages were flushed from Q 3\n", count );
204
205  Fill_buffer( "BUFFER 1 TO Q 3", buffer );
206  puts( "TA1 - rtems_message_queue_send - BUFFER 1 TO Q 3" );
207  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
208  directive_failed( status, "rtems_message_queue_send" );
209
210  Fill_buffer( "BUFFER 2 TO Q 3", buffer );
211  puts( "TA1 - rtems_message_queue_send - BUFFER 2 TO Q 3" );
212  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
213  directive_failed( status, "rtems_message_queue_send" );
214
215  Fill_buffer( "BUFFER 3 TO Q 3", buffer );
216  puts( "TA1 - rtems_message_queue_send - BUFFER 3 TO Q 3" );
217  status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
218  directive_failed( status, "rtems_message_queue_send" );
219
220  puts( "TA1 - rtems_message_queue_flush - Q 3" );
221  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
222  printf( "TA1 - %d messages were flushed from Q 3\n", count );
223
224  puts( "TA1 - rtems_message_queue_send until all message buffers consumed" );
225  while ( FOREVER ) {
226    status = rtems_message_queue_send( Queue_id[ 3 ], buffer, 16 );
227    if ( status == RTEMS_TOO_MANY ) break;
228    directive_failed( status, "rtems_message_queue_send loop" );
229  }
230
231  puts( "TA1 - all message buffers consumed" );
232  puts( "TA1 - rtems_message_queue_flush - Q 3" );
233  status = rtems_message_queue_flush( Queue_id[ 3 ], &count );
234  printf( "TA1 - %d messages were flushed from Q 3\n", count );
235
236pause();
237
238  puts( "TA1 - create message queue of 20 bytes on queue 1" );
239  status = rtems_message_queue_create(
240    Queue_name[ 1 ],
241    100,
242    20,
243    RTEMS_DEFAULT_ATTRIBUTES,
244    &Queue_id[ 1 ]
245  );
246  directive_failed( status, "rtems_message_queue_create of Q1; 20 bytes each" );
247  status = rtems_message_queue_send( Queue_id[ 3 ], big_send_buffer, 40 );
248  fatal_directive_status(status, RTEMS_INVALID_SIZE, "expected RTEMS_INVALID_SIZE");
249 
250  puts( "TA1 - rtems_message_queue_delete - delete queue 1" );
251  status = rtems_message_queue_delete( Queue_id[ 1 ] );
252  directive_failed( status, "rtems_message_queue_delete" );
253
254pause();
255 
256  puts( "TA1 - rtems_message_queue_create - variable sizes " );
257  for (queue_size = 1; queue_size < 1030; queue_size++)
258  {
259      status = rtems_message_queue_create(
260          Queue_name[ 1 ],
261          2,            /* just 2 msgs each */
262          queue_size,
263          RTEMS_DEFAULT_ATTRIBUTES,
264          &Queue_id[ 1 ]
265          );
266      if (status != RTEMS_SUCCESSFUL)
267      {
268          printf("TA1 - msq que size: %d\n", queue_size);
269          directive_failed( status, "rtems_message_queue_create of Q1" );
270      }
271
272      status = rtems_message_queue_delete( Queue_id[ 1 ] );
273      directive_failed( status, "rtems_message_queue_delete" );
274  }
275 
276  puts( "TA1 - rtems_message_queue_create and send - variable sizes " );
277  for (queue_size = 1; queue_size < 1030; queue_size++)
278  {
279      /* printf("TA1 - message queue size: %d\n", queue_size); */
280
281      status = rtems_message_queue_create(
282          Queue_name[ 1 ],
283          2,            /* just 2 msgs each */
284          queue_size,
285          RTEMS_DEFAULT_ATTRIBUTES,
286          &Queue_id[ 1 ]
287          );
288
289      directive_failed( status, "rtems_message_queue_create of Q1" );
290
291      dope_buffer(big_send_buffer, sizeof(big_send_buffer), queue_size);
292      memset(big_receive_buffer, 'Z', sizeof(big_receive_buffer));
293
294      /* send a msg too big */
295      status = rtems_message_queue_send( Queue_id[ 1 ],
296                                         big_send_buffer,
297                                         queue_size + 1 );
298
299      fatal_directive_status(status,
300                             RTEMS_INVALID_SIZE,
301                             "rtems_message_queue_send too large");
302
303      /* send a msg that is just right */
304      status = rtems_message_queue_send(Queue_id[ 1 ],
305                                        big_send_buffer,
306                                        queue_size);
307      directive_failed(status, "rtems_message_queue_send exact size");
308
309      /* now read and verify the message just sent */
310      status = rtems_message_queue_receive(Queue_id[ 1 ],
311                                           big_receive_buffer,
312                                           &size,
313                                           RTEMS_DEFAULT_OPTIONS,
314                                           1 * TICKS_PER_SECOND);
315      directive_failed(status, "rtems_message_queue_receive exact size");
316      if (size != queue_size)
317      {
318          puts("TA1 - exact size size match failed");
319          exit(1);
320      }
321
322      if (memcmp(big_send_buffer, big_receive_buffer, size) != 0)
323      {
324          puts("TA1 - exact size data match failed");
325          exit(1);
326      }
327
328      for (cp = (big_receive_buffer + size);
329           cp < (big_receive_buffer + sizeof(big_receive_buffer));
330           cp++)
331          if (*cp != 'Z')
332          {
333              puts("TA1 - exact size overrun match failed");
334              exit(1);
335          }
336         
337      /* all done with this one; delete it */
338      status = rtems_message_queue_delete( Queue_id[ 1 ] );
339      directive_failed( status, "rtems_message_queue_delete" );
340  }
341 
342  puts( "*** END OF TEST 13 ***" );
343  exit( 0 );
344}
Note: See TracBrowser for help on using the repository browser.