OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [tests/] [mptests/] [mp09/] [task1.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-1999.
12
 *  On-Line Applications Research Corporation (OAR).
13
 *
14
 *  The license and distribution terms for this file may be
15
 *  found in the file LICENSE in this distribution or at
16
 *  http://www.OARcorp.com/rtems/license.html.
17
 *
18
 *  $Id: task1.c,v 1.2 2001-09-27 12:02:21 chris Exp $
19
 */
20
 
21
#include "system.h"
22
 
23
char buffer1[16] = "123456789012345";
24
char buffer2[16] = "abcdefghijklmno";
25
char buffer3[16] = "ABCDEFGHIJKLMNO";
26
char buffer4[16] = "PQRSTUVWXYZ(){}";
27
 
28
rtems_task Test_task(
29
  rtems_task_argument argument
30
)
31
{
32
  rtems_status_code status;
33
  rtems_unsigned32  count;
34
  rtems_unsigned32  size;
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( "%d 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, 16 );
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( "%d 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
      &size,
83
      RTEMS_DEFAULT_OPTIONS,
84
      RTEMS_NO_TIMEOUT
85
    );
86
    fatal_directive_status(
87
      status,
88
      RTEMS_OBJECT_WAS_DELETED,
89
      "rtems_message_queue_receive"
90
    );
91
    puts( "\nGlobal message queue deleted" );
92
  }
93
  else {                   /* node == 1 */
94
    Receive_messages();
95
    Send_messages();
96
 
97
    puts( "Delaying for 5 seconds" );
98
    status = rtems_task_wake_after( 5*TICKS_PER_SECOND );
99
    directive_failed( status, "rtems_task_wake_after" );
100
 
101
    puts( "Deleting Message queue" );
102
    status = rtems_message_queue_delete( Queue_id[ 1 ] );
103
    directive_failed( status, "rtems_message_queue_delete" );
104
  }
105
 
106
  puts( "*** END OF TEST 9 ***" );
107
  exit( 0 );
108
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.