source: rtems/testsuites/mptests/mp13/task1.c @ 24f8915

5
Last change on this file since 24f8915 was a00dff42, checked in by Sebastian Huber <sebastian.huber@…>, on 12/12/19 at 05:37:01

rtems: Add and use rtems_object_get_local_node()

Update #3841.

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*  Test_task1
2 *
3 *  This task attempts to receive a message from a global message queue.
4 *  If running on the node on which the queue resides, the wait is
5 *  forever, otherwise it times out on a remote message queue.
6 *
7 *  Input parameters:
8 *    argument - task argument
9 *
10 *  Output parameters:  NONE
11 *
12 *  COPYRIGHT (c) 1989-2009.
13 *  On-Line Applications Research Corporation (OAR).
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.rtems.org/license/LICENSE.
18 */
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include "system.h"
25
26rtems_task Test_task1(
27  rtems_task_argument argument
28)
29{
30  char              receive_buffer[16];
31  size_t            size;
32  rtems_status_code status;
33
34  puts( "Getting QID of message queue" );
35
36  do {
37    status = rtems_message_queue_ident(
38      Queue_name[ 1 ],
39      RTEMS_SEARCH_ALL_NODES,
40      &Queue_id[ 1 ]
41    );
42  } while ( !rtems_is_status_successful( status ) );
43
44  if ( rtems_object_get_local_node() == 1 ) {
45    puts( "Receiving message ..." );
46    status = rtems_message_queue_receive(
47      Queue_id[ 1 ],
48      receive_buffer,
49      &size,
50      RTEMS_DEFAULT_OPTIONS,
51      RTEMS_NO_TIMEOUT
52    );
53    puts( "How did I get back from here????" );
54    directive_failed( status, "rtems_message_queue_receive" );
55  }
56
57  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
58  directive_failed( status, "rtems_task_wake_after" );
59
60  puts( "Receiving message ..." );
61  status = rtems_message_queue_receive(
62    Queue_id[ 1 ],
63    (long (*)[4])receive_buffer,
64    &size,
65    RTEMS_DEFAULT_OPTIONS,
66    2 * rtems_clock_get_ticks_per_second()
67  );
68  fatal_directive_status(status, RTEMS_TIMEOUT, "rtems_message_queue_receive");
69  puts( "rtems_message_queue_receive correctly returned RTEMS_TIMEOUT" );
70
71  puts( "Deleting self" );
72  rtems_task_exit();
73}
Note: See TracBrowser for help on using the repository browser.