source: rtems/testsuites/mptests/mp09/task1.c @ 60b791ad

4.104.114.84.9
Last change on this file since 60b791ad was 60b791ad, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 17, 1998 at 11:46:28 PM

updated copyright to 1998

  • Property mode set to 100644
File size: 3.0 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-1998.
12 *  On-Line Applications Research Corporation (OAR).
13 *  Copyright assigned to U.S. Government, 1994.
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.OARcorp.com/rtems/license.html.
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  rtems_unsigned32  size;
36  char              receive_buffer[16];
37
38  status = rtems_task_wake_after( TICKS_PER_SECOND );
39  directive_failed( status, "rtems_task_wake_after" );
40
41  puts( "Getting QID of message queue" );
42
43  do {
44    status = rtems_message_queue_ident(
45      Queue_name[ 1 ],
46      RTEMS_SEARCH_ALL_NODES,
47      &Queue_id[ 1 ]
48    );
49  } while ( !rtems_is_status_successful( status ) );
50
51  if ( Multiprocessing_configuration.node == 2 ) {
52    status = rtems_message_queue_delete( Queue_id[ 1 ] );
53    fatal_directive_status(
54      status,
55      RTEMS_ILLEGAL_ON_REMOTE_OBJECT,
56      "rtems_message_queue_delete"
57    );
58    puts(
59  "rtems_message_queue_delete correctly returned RTEMS_ILLEGAL_ON_REMOTE_OBJECT"
60    );
61
62    Send_messages();
63    Receive_messages();
64
65    puts( "Flushing remote empty queue" );
66    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
67    directive_failed( status, "rtems_message_queue_flush" );
68    printf( "%d messages were flushed on the remote queue\n", count );
69
70    puts( "Send messages to be flushed from remote queue" );
71    status = rtems_message_queue_send( Queue_id[ 1 ], (long (*)[4])buffer1, 16 );
72    directive_failed( status, "rtems_message_queue_send" );
73
74    puts( "Flushing remote queue" );
75    status = rtems_message_queue_flush( Queue_id[ 1 ], &count );
76    directive_failed( status, "rtems_message_queue_flush" );
77    printf( "%d messages were flushed on the remote queue\n", count );
78
79    puts( "Waiting for message queue to be deleted" );
80    status = rtems_message_queue_receive(
81      Queue_id[ 1 ],
82      (long (*)[4])receive_buffer,
83      &size,
84      RTEMS_DEFAULT_OPTIONS,
85      RTEMS_NO_TIMEOUT
86    );
87    fatal_directive_status(
88      status,
89      RTEMS_OBJECT_WAS_DELETED,
90      "rtems_message_queue_receive"
91    );
92    puts( "\nGlobal message queue deleted" );
93  }
94  else {                   /* node == 1 */
95    Receive_messages();
96    Send_messages();
97
98    puts( "Delaying for 5 seconds" );
99    status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
100    directive_failed( status, "rtems_task_wake_after" );
101
102    puts( "Deleting Message queue" );
103    status = rtems_message_queue_delete( Queue_id[ 1 ] );
104    directive_failed( status, "rtems_message_queue_delete" );
105  }
106
107  puts( "*** END OF TEST 9 ***" );
108  exit( 0 );
109}
Note: See TracBrowser for help on using the repository browser.