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-1997. |
---|
14 | * On-Line Applications Research Corporation (OAR). |
---|
15 | * Copyright assigned to U.S. Government, 1994. |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may in |
---|
18 | * the file LICENSE in this distribution or at |
---|
19 | * http://www.OARcorp.com/rtems/license.html. |
---|
20 | * |
---|
21 | * $Id$ |
---|
22 | */ |
---|
23 | |
---|
24 | #include "system.h" |
---|
25 | |
---|
26 | rtems_task Message_queue_task( |
---|
27 | rtems_task_argument index |
---|
28 | ) |
---|
29 | { |
---|
30 | rtems_status_code status; |
---|
31 | rtems_unsigned32 count; |
---|
32 | rtems_unsigned32 yield_count; |
---|
33 | rtems_unsigned32 *buffer_count; |
---|
34 | rtems_unsigned32 *overflow_count; |
---|
35 | rtems_unsigned32 size; |
---|
36 | |
---|
37 | Msg_buffer[ index ][0] = 0; |
---|
38 | Msg_buffer[ index ][1] = 0; |
---|
39 | Msg_buffer[ index ][2] = 0; |
---|
40 | Msg_buffer[ index ][3] = 0; |
---|
41 | |
---|
42 | puts( "Getting ID of msg queue" ); |
---|
43 | while ( FOREVER ) { |
---|
44 | status = rtems_message_queue_ident( |
---|
45 | Queue_name[ 1 ], |
---|
46 | RTEMS_SEARCH_ALL_NODES, |
---|
47 | &Queue_id[ 1 ] |
---|
48 | ); |
---|
49 | if ( status == RTEMS_SUCCESSFUL ) |
---|
50 | break; |
---|
51 | puts( "rtems_message_queue_ident FAILED!!" ); |
---|
52 | rtems_task_wake_after(2); |
---|
53 | } |
---|
54 | |
---|
55 | if ( Multiprocessing_configuration.node == 1 ) { |
---|
56 | status = rtems_message_queue_send( |
---|
57 | Queue_id[ 1 ], |
---|
58 | (long (*)[4])Msg_buffer[ index ], |
---|
59 | 16 |
---|
60 | ); |
---|
61 | directive_failed( status, "rtems_message_queue_send" ); |
---|
62 | overflow_count = &Msg_buffer[ index ][0]; |
---|
63 | buffer_count = &Msg_buffer[ index ][1]; |
---|
64 | } else { |
---|
65 | overflow_count = &Msg_buffer[ index ][2]; |
---|
66 | buffer_count = &Msg_buffer[ index ][3]; |
---|
67 | } |
---|
68 | |
---|
69 | while ( Stop_Test == FALSE ) { |
---|
70 | yield_count = 100; |
---|
71 | |
---|
72 | for ( count=MESSAGE_DOT_COUNT ; Stop_Test == FALSE && count ; count-- ) { |
---|
73 | status = rtems_message_queue_receive( |
---|
74 | Queue_id[ 1 ], |
---|
75 | (long (*)[4])Msg_buffer[ index ], |
---|
76 | &size, |
---|
77 | RTEMS_DEFAULT_OPTIONS, |
---|
78 | RTEMS_NO_TIMEOUT |
---|
79 | ); |
---|
80 | directive_failed( status, "rtems_message_queue_receive" ); |
---|
81 | |
---|
82 | if ( *buffer_count == (rtems_unsigned32)0xffffffff ) { |
---|
83 | *buffer_count = 0; |
---|
84 | *overflow_count += 1; |
---|
85 | } else |
---|
86 | *buffer_count += 1; |
---|
87 | |
---|
88 | status = rtems_message_queue_send( |
---|
89 | Queue_id[ 1 ], |
---|
90 | (long (*)[4])Msg_buffer[ index ], |
---|
91 | 16 |
---|
92 | ); |
---|
93 | directive_failed( status, "rtems_message_queue_send" ); |
---|
94 | |
---|
95 | if (Stop_Test == FALSE) |
---|
96 | if ( Multiprocessing_configuration.node == 1 && --yield_count == 0 ) { |
---|
97 | status = rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ); |
---|
98 | directive_failed( status, "rtems_task_wake_after" ); |
---|
99 | |
---|
100 | yield_count = 100; |
---|
101 | } |
---|
102 | } |
---|
103 | put_dot( 'm' ); |
---|
104 | } |
---|
105 | |
---|
106 | Exit_test(); |
---|
107 | } |
---|