[ac7d5ef0] | 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, 1990, 1991, 1992, 1993, 1994. |
---|
| 13 | * On-Line Applications Research Corporation (OAR). |
---|
| 14 | * All rights assigned to U.S. Government, 1994. |
---|
| 15 | * |
---|
| 16 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
| 17 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
| 18 | * notice must appear in all copies of this file and its derivatives. |
---|
| 19 | * |
---|
[3235ad9] | 20 | * $Id$ |
---|
[ac7d5ef0] | 21 | */ |
---|
| 22 | |
---|
| 23 | #include "system.h" |
---|
| 24 | |
---|
| 25 | rtems_task Test_task1( |
---|
| 26 | rtems_task_argument argument |
---|
| 27 | ) |
---|
| 28 | { |
---|
| 29 | char receive_buffer[16]; |
---|
[4b374f36] | 30 | rtems_unsigned32 size; |
---|
[ac7d5ef0] | 31 | rtems_status_code status; |
---|
| 32 | |
---|
| 33 | puts( "Getting QID of message queue" ); |
---|
| 34 | |
---|
| 35 | do { |
---|
| 36 | status = rtems_message_queue_ident( |
---|
| 37 | Queue_name[ 1 ], |
---|
| 38 | RTEMS_SEARCH_ALL_NODES, |
---|
| 39 | &Queue_id[ 1 ] |
---|
| 40 | ); |
---|
| 41 | } while ( !rtems_is_status_successful( status ) ); |
---|
| 42 | |
---|
| 43 | if ( Multiprocessing_configuration.node == 1 ) { |
---|
| 44 | puts( "Receiving message ..." ); |
---|
| 45 | status = rtems_message_queue_receive( |
---|
| 46 | Queue_id[ 1 ], |
---|
| 47 | (long (*)[4])receive_buffer, |
---|
[4b374f36] | 48 | &size, |
---|
[ac7d5ef0] | 49 | RTEMS_DEFAULT_OPTIONS, |
---|
| 50 | RTEMS_NO_TIMEOUT |
---|
| 51 | ); |
---|
| 52 | puts( "How did I get back from here????" ); |
---|
| 53 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | status = rtems_task_wake_after( TICKS_PER_SECOND ); |
---|
| 57 | directive_failed( status, "rtems_task_wake_after" ); |
---|
| 58 | |
---|
| 59 | puts( "Receiving message ..." ); |
---|
| 60 | status = rtems_message_queue_receive( |
---|
| 61 | Queue_id[ 1 ], |
---|
| 62 | (long (*)[4])receive_buffer, |
---|
[4b374f36] | 63 | &size, |
---|
[ac7d5ef0] | 64 | RTEMS_DEFAULT_OPTIONS, |
---|
| 65 | 2 * TICKS_PER_SECOND |
---|
| 66 | ); |
---|
| 67 | fatal_directive_status(status, RTEMS_TIMEOUT, "rtems_message_queue_receive"); |
---|
| 68 | puts( "rtems_message_queue_receive correctly returned RTEMS_TIMEOUT" ); |
---|
| 69 | |
---|
| 70 | puts( "Deleting self" ); |
---|
| 71 | status = rtems_task_delete( RTEMS_SELF ); |
---|
| 72 | directive_failed( status, "rtems_task_delete of RTEMS_SELF" ); |
---|
| 73 | } |
---|