source: rtems/testsuites/mptests/mp13/task1.c

Last change on this file was 42d4ebe, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:01:34

testsuites/mptests/*: Change license to BSD-2.

Updates #3053.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*  Test_task1
4 *
5 *  This task attempts to receive a message from a global message queue.
6 *  If running on the node on which the queue resides, the wait is
7 *  forever, otherwise it times out on a remote message queue.
8 *
9 *  Input parameters:
10 *    argument - task argument
11 *
12 *  Output parameters:  NONE
13 *
14 *  COPYRIGHT (c) 1989-2009.
15 *  On-Line Applications Research Corporation (OAR).
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifdef HAVE_CONFIG_H
40#include "config.h"
41#endif
42
43#include "system.h"
44
45rtems_task Test_task1(
46  rtems_task_argument argument
47)
48{
49  char              receive_buffer[16];
50  size_t            size;
51  rtems_status_code status;
52
53  puts( "Getting QID of message queue" );
54
55  do {
56    status = rtems_message_queue_ident(
57      Queue_name[ 1 ],
58      RTEMS_SEARCH_ALL_NODES,
59      &Queue_id[ 1 ]
60    );
61  } while ( !rtems_is_status_successful( status ) );
62
63  if ( rtems_object_get_local_node() == 1 ) {
64    puts( "Receiving message ..." );
65    status = rtems_message_queue_receive(
66      Queue_id[ 1 ],
67      receive_buffer,
68      &size,
69      RTEMS_DEFAULT_OPTIONS,
70      RTEMS_NO_TIMEOUT
71    );
72    puts( "How did I get back from here????" );
73    directive_failed( status, "rtems_message_queue_receive" );
74  }
75
76  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
77  directive_failed( status, "rtems_task_wake_after" );
78
79  puts( "Receiving message ..." );
80  status = rtems_message_queue_receive(
81    Queue_id[ 1 ],
82    (long (*)[4])receive_buffer,
83    &size,
84    RTEMS_DEFAULT_OPTIONS,
85    2 * rtems_clock_get_ticks_per_second()
86  );
87  fatal_directive_status(status, RTEMS_TIMEOUT, "rtems_message_queue_receive");
88  puts( "rtems_message_queue_receive correctly returned RTEMS_TIMEOUT" );
89
90  puts( "Deleting self" );
91  rtems_task_exit();
92}
Note: See TracBrowser for help on using the repository browser.