source: rtems/testsuites/mptests/mp09/task1.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on May 11, 1995 at 5:39:37 PM

Initial revision

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*  Test_task
2 *
3 *  This task tests global message queue operations.  It also generates
4 *  an error condition.
5 *
6 *  Input parameters:
7 *    argument - task argument
8 *
9 *  Output parameters:  NONE
10 *
11 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
12 *  On-Line Applications Research Corporation (OAR).
13 *  All rights assigned to U.S. Government, 1994.
14 *
15 *  This material may be reproduced by or for the U.S. Government pursuant
16 *  to the copyright license under the clause at DFARS 252.227-7013.  This
17 *  notice must appear in all copies of this file and its derivatives.
18 *
19 *  $Id$
20 */
21
22#include "system.h"
23
24char buffer1[16] = "123456789012345";
25char buffer2[16] = "abcdefghijklmno";
26char buffer3[16] = "ABCDEFGHIJKLMNO";
27char buffer4[16] = "PQRSTUVWXYZ(){}";
28
29rtems_task Test_task(
30  rtems_task_argument argument
31)
32{
33  rtems_status_code status;
34  rtems_unsigned32  count;
35  char              receive_buffer[16];
36
37  status = rtems_task_wake_after( TICKS_PER_SECOND );
38  directive_failed( status, "rtems_task_wake_after" );
39
40  puts( "Getting QID of message queue" );
41
42  do {
43    status = rtems_message_queue_ident(
44      Queue_name[ 1 ],
45      RTEMS_SEARCH_ALL_NODES,
46      &Queue_id[ 1 ]
47    );
48  } while ( !rtems_is_status_successful( status ) );
49
50  if ( Multiprocessing_configuration.node == 2 ) {
51    status = rtems_message_queue_delete( Queue_id[ 1 ] );
52    fatal_directive_status(
53      status,
54      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
55      "rtems_message_queue_delete"
56    );
57    puts(
58  "rtems_message_queue_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
59    );
60
61    Send_messages();
62    Receive_messages();
63
64    puts( "Flushing remote empty queue" );
65    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
66    directive_failed( status, "rtems_message_queue_flush" );
67    printf( "%02d messages were flushed on the remote queue\n", count );
68
69    puts( "Send messages to be flushed from remote queue" );
70    status = rtems_message_queue_send( Queue_id[ 1 ], (long (*)[4])buffer1 );
71    directive_failed( status, "rtems_message_queue_send" );
72
73    puts( "Flushing remote queue" );
74    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
75    directive_failed( status, "rtems_message_queue_flush" );
76    printf( "%02d messages were flushed on the remote queue\n", count );
77
78    puts( "Waiting for message queue to be deleted" );
79    status = rtems_message_queue_receive(
80      Queue_id[ 1 ],
81      (long (*)[4])receive_buffer,
82      RTEMS_DEFAULT_OPTIONS,
83      RTEMS_NO_TIMEOUT
84    );
85    fatal_directive_status(
86      status,
87      RTEMS_OBJECT_WAS_DELETED,
88      "rtems_message_queue_receive"
89    );
90    puts( "\nGlobal message queue deleted" );
91  }
92  else {                   /* node == 1 */
93    Receive_messages();
94    Send_messages();
95
96    puts( "Delaying for 5 seconds" );
97    status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
98    directive_failed( status, "rtems_task_wake_after" );
99
100    puts( "Deleting Message queue" );
101    status = rtems_message_queue_delete( Queue_id[ 1 ] );
102    directive_failed( status, "rtems_message_queue_delete" );
103  }
104
105  puts( "*** END OF TEST 9 ***" );
106  exit( 0 );
107}
Note: See TracBrowser for help on using the repository browser.