source: rtems/testsuites/mptests/mp14/msgtask1.c @ df40cc9

4.115
Last change on this file since df40cc9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*  Message_queue_task
2 *
3 *  This task continuously sends messages to and receives messages from
4 *  a global message queue.    The message buffer is viewed as an array
5 *  of two sixty-four bit counts which are incremented when a message is
6 *  received.
7 *
8 *  Input parameters:
9 *    argument - task argument
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.org/license/LICENSE.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include "config.h"
23#endif
24
25#include "system.h"
26
27rtems_task Message_queue_task(
28  rtems_task_argument index
29)
30{
31  rtems_status_code  status;
32  uint32_t     count;
33  uint32_t     yield_count;
34  uint32_t    *buffer_count;
35  uint32_t    *overflow_count;
36  size_t       size;
37
38  Msg_buffer[ index ][0] = 0;
39  Msg_buffer[ index ][1] = 0;
40  Msg_buffer[ index ][2] = 0;
41  Msg_buffer[ index ][3] = 0;
42
43  puts( "Getting ID of msg queue" );
44  while ( FOREVER ) {
45    status = rtems_message_queue_ident(
46      Queue_name[ 1 ],
47      RTEMS_SEARCH_ALL_NODES,
48      &Queue_id[ 1 ]
49    );
50    if ( status == RTEMS_SUCCESSFUL )
51      break;
52    puts( "rtems_message_queue_ident FAILED!!" );
53    rtems_task_wake_after(2);
54  }
55
56  if ( Multiprocessing_configuration.node == 1 ) {
57      status = rtems_message_queue_send(
58        Queue_id[ 1 ],
59        (long (*)[4])Msg_buffer[ index ],
60        16
61      );
62      directive_failed( status, "rtems_message_queue_send" );
63      overflow_count = &Msg_buffer[ index ][0];
64      buffer_count   = &Msg_buffer[ index ][1];
65  } else {
66      overflow_count = &Msg_buffer[ index ][2];
67      buffer_count   = &Msg_buffer[ index ][3];
68  }
69
70  while ( Stop_Test == false ) {
71    yield_count = 100;
72
73    for ( count=MESSAGE_DOT_COUNT ; Stop_Test == false && count ; count-- ) {
74      status = rtems_message_queue_receive(
75        Queue_id[ 1 ],
76        Msg_buffer[ index ],
77        &size,
78        RTEMS_DEFAULT_OPTIONS,
79        RTEMS_NO_TIMEOUT
80      );
81      directive_failed( status, "rtems_message_queue_receive" );
82
83      if ( *buffer_count == (uint32_t)0xffffffff ) {
84        *buffer_count    = 0;
85        *overflow_count += 1;
86      } else
87        *buffer_count += 1;
88
89      status = rtems_message_queue_send(
90        Queue_id[ 1 ],
91        Msg_buffer[ index ],
92        16
93      );
94      directive_failed( status, "rtems_message_queue_send" );
95
96      if (Stop_Test == false)
97        if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) {
98          status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
99          directive_failed( status, "rtems_task_wake_after" );
100
101          yield_count = 100;
102        }
103    }
104    put_dot( 'm' );
105  }
106
107  Exit_test();
108}
Note: See TracBrowser for help on using the repository browser.