source: rtems/cpukit/rtems/src/msgmp.c @ ac7d5ef0

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 10.3 KB
Line 
1/*
2 *  Multiprocessing Support for the Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/message.h>
18#include <rtems/mpci.h>
19#include <rtems/msgmp.h>
20#include <rtems/object.h>
21#include <rtems/options.h>
22#include <rtems/thread.h>
23#include <rtems/watchdog.h>
24
25/*PAGE
26 *
27 *  _Message_queue_MP_Send_process_packet
28 *
29 */
30
31void _Message_queue_MP_Send_process_packet (
32  Message_queue_MP_Remote_operations  operation,
33  Objects_Id                          message_queue_id,
34  Objects_Name                        name,
35  Objects_Id                          proxy_id
36)
37{
38  Message_queue_MP_Packet *the_packet;
39  unsigned32               node;
40
41  switch ( operation ) {
42
43    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
44    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
45    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
46
47      the_packet                    = _Message_queue_MP_Get_packet();
48      the_packet->Prefix.the_class  = RTEMS_MP_PACKET_MESSAGE_QUEUE;
49      the_packet->Prefix.length     = sizeof ( Message_queue_MP_Packet );
50      the_packet->Prefix.to_convert = sizeof ( Message_queue_MP_Packet );
51      the_packet->operation         = operation;
52      the_packet->Prefix.id         = message_queue_id;
53      the_packet->name              = name;
54      the_packet->proxy_id          = proxy_id;
55
56      if ( operation == MESSAGE_QUEUE_MP_EXTRACT_PROXY )
57         node = rtems_get_node( message_queue_id );
58      else
59         node = MPCI_ALL_NODES;
60
61      _MPCI_Send_process_packet( node, &the_packet->Prefix );
62      break;
63
64    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
65    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
66    case MESSAGE_QUEUE_MP_SEND_REQUEST:
67    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
68    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
69    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
70    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
71    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
72    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
73    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
74      break;
75
76  }
77}
78
79/*PAGE
80 *
81 *  _Message_queue_MP_Send_request_packet
82 *
83 */
84
85rtems_status_code _Message_queue_MP_Send_request_packet (
86  Message_queue_MP_Remote_operations  operation,
87  Objects_Id                          message_queue_id,
88  Message_queue_Buffer               *buffer,
89  rtems_option                     option_set,
90  rtems_interval                   timeout
91)
92{
93  Message_queue_MP_Packet *the_packet;
94
95  switch ( operation ) {
96
97    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
98    case MESSAGE_QUEUE_MP_SEND_REQUEST:
99    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
100    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
101    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
102
103      the_packet                    = _Message_queue_MP_Get_packet();
104      the_packet->Prefix.the_class  = RTEMS_MP_PACKET_MESSAGE_QUEUE;
105      the_packet->Prefix.length     = sizeof ( Message_queue_MP_Packet );
106      the_packet->Prefix.to_convert = sizeof ( Message_queue_MP_Packet ) -
107                         sizeof ( Message_queue_Buffer );
108      if ( ! _Options_Is_no_wait(option_set))
109          the_packet->Prefix.timeout = timeout;
110
111      the_packet->operation         = operation;
112      the_packet->Prefix.id         = message_queue_id;
113      the_packet->option_set        = option_set;
114
115      if ( buffer )
116        _Message_queue_Copy_buffer( buffer, &the_packet->Buffer );
117
118      return
119        _MPCI_Send_request_packet(
120          rtems_get_node( message_queue_id ),
121          &the_packet->Prefix,
122          STATES_WAITING_FOR_MESSAGE
123        );
124      break;
125
126    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
127    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
128    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
129    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
130    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
131    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
132    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
133    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
134      break;
135
136  }
137  /*
138   *  The following line is included to satisfy compilers which
139   *  produce warnings when a function does not end with a return.
140   */
141  return RTEMS_SUCCESSFUL;
142}
143
144/*PAGE
145 *
146 *  _Message_queue_MP_Send_response_packet
147 *
148 */
149
150void _Message_queue_MP_Send_response_packet (
151  Message_queue_MP_Remote_operations  operation,
152  Objects_Id                          message_queue_id,
153  Thread_Control                     *the_thread
154)
155{
156  Message_queue_MP_Packet *the_packet;
157
158  switch ( operation ) {
159
160    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
161    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
162    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
163    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
164    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
165
166      the_packet = ( Message_queue_MP_Packet *) the_thread->receive_packet;
167
168/*
169 *  The packet being returned already contains the class, length, and
170 *  to_convert fields, therefore they are not set in this routine.
171 */
172      the_packet->operation = operation;
173      the_packet->Prefix.id = the_packet->Prefix.source_tid;
174
175      _MPCI_Send_response_packet(
176        rtems_get_node( the_packet->Prefix.source_tid ),
177        &the_packet->Prefix
178      );
179      break;
180
181    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
182    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
183    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
184    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
185    case MESSAGE_QUEUE_MP_SEND_REQUEST:
186    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
187    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
188    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
189      break;
190
191  }
192}
193
194/*PAGE
195 *
196 *
197 *  _Message_queue_MP_Process_packet
198 *
199 */
200
201void _Message_queue_MP_Process_packet (
202  rtems_packet_prefix   *the_packet_prefix
203)
204{
205  Message_queue_MP_Packet *the_packet;
206  Thread_Control          *the_thread;
207  boolean                  ignored;
208
209  the_packet = (Message_queue_MP_Packet *) the_packet_prefix;
210
211  switch ( the_packet->operation ) {
212
213    case MESSAGE_QUEUE_MP_ANNOUNCE_CREATE:
214
215      ignored = _Objects_MP_Open(
216                  &_Message_queue_Information,
217                  the_packet->name,
218                  the_packet->Prefix.id,
219                  TRUE
220                );
221
222      _MPCI_Return_packet( the_packet_prefix );
223      break;
224
225    case MESSAGE_QUEUE_MP_ANNOUNCE_DELETE:
226
227      _Objects_MP_Close( &_Message_queue_Information, the_packet->Prefix.id );
228
229      _MPCI_Return_packet( the_packet_prefix );
230      break;
231
232    case MESSAGE_QUEUE_MP_EXTRACT_PROXY:
233
234      the_thread = _Thread_MP_Find_proxy( the_packet->proxy_id );
235
236      if ( ! _Thread_Is_null( the_thread ) )
237         _Thread_queue_Extract( the_thread->Wait.queue, the_thread );
238
239      _MPCI_Return_packet( the_packet_prefix );
240      break;
241
242    case MESSAGE_QUEUE_MP_RECEIVE_REQUEST:
243
244      the_packet->Prefix.return_code = rtems_message_queue_receive(
245        the_packet->Prefix.id,
246        &the_packet->Buffer,
247        the_packet->option_set,
248        the_packet->Prefix.timeout
249      );
250
251      if ( ! _Status_Is_proxy_blocking( the_packet->Prefix.return_code ) )
252        _Message_queue_MP_Send_response_packet(
253          MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
254          the_packet->Prefix.id,
255          _Thread_Executing
256        );
257      break;
258
259    case MESSAGE_QUEUE_MP_RECEIVE_RESPONSE:
260
261      the_thread = _MPCI_Process_response( the_packet_prefix );
262
263      _Message_queue_Copy_buffer(
264        &the_packet->Buffer,
265        (Message_queue_Buffer *) the_thread->Wait.return_argument
266      );
267
268      _MPCI_Return_packet( the_packet_prefix );
269      break;
270
271    case MESSAGE_QUEUE_MP_SEND_REQUEST:
272
273      the_packet->Prefix.return_code = rtems_message_queue_send(
274        the_packet->Prefix.id,
275        &the_packet->Buffer
276      );
277
278      _Message_queue_MP_Send_response_packet(
279        MESSAGE_QUEUE_MP_SEND_RESPONSE,
280        the_packet->Prefix.id,
281        _Thread_Executing
282      );
283      break;
284
285    case MESSAGE_QUEUE_MP_SEND_RESPONSE:
286    case MESSAGE_QUEUE_MP_URGENT_RESPONSE:
287
288      the_thread = _MPCI_Process_response( the_packet_prefix );
289
290      _MPCI_Return_packet( the_packet_prefix );
291      break;
292
293    case MESSAGE_QUEUE_MP_URGENT_REQUEST:
294
295      the_packet->Prefix.return_code = rtems_message_queue_urgent(
296        the_packet->Prefix.id,
297        &the_packet->Buffer
298      );
299
300      _Message_queue_MP_Send_response_packet(
301        MESSAGE_QUEUE_MP_URGENT_RESPONSE,
302        the_packet->Prefix.id,
303        _Thread_Executing
304      );
305      break;
306
307    case MESSAGE_QUEUE_MP_BROADCAST_REQUEST:
308
309      the_packet->Prefix.return_code = rtems_message_queue_broadcast(
310        the_packet->Prefix.id,
311        &the_packet->Buffer,
312        &the_packet->count
313      );
314
315      _Message_queue_MP_Send_response_packet(
316        MESSAGE_QUEUE_MP_BROADCAST_RESPONSE,
317        the_packet->Prefix.id,
318        _Thread_Executing
319      );
320      break;
321
322    case MESSAGE_QUEUE_MP_BROADCAST_RESPONSE:
323    case MESSAGE_QUEUE_MP_FLUSH_RESPONSE:
324
325      the_thread = _MPCI_Process_response( the_packet_prefix );
326
327      *(unsigned32 *)the_thread->Wait.return_argument = the_packet->count;
328
329      _MPCI_Return_packet( the_packet_prefix );
330      break;
331
332    case MESSAGE_QUEUE_MP_FLUSH_REQUEST:
333
334      the_packet->Prefix.return_code = rtems_message_queue_flush(
335        the_packet->Prefix.id,
336        &the_packet->count
337      );
338
339      _Message_queue_MP_Send_response_packet(
340        MESSAGE_QUEUE_MP_FLUSH_RESPONSE,
341        the_packet->Prefix.id,
342        _Thread_Executing
343      );
344      break;
345
346  }
347}
348
349/*PAGE
350 *
351 *  _Message_queue_MP_Send_object_was_deleted
352 *
353 */
354
355void _Message_queue_MP_Send_object_was_deleted (
356  Thread_Control  *the_proxy
357)
358{
359  the_proxy->receive_packet->return_code = RTEMS_OBJECT_WAS_DELETED;
360
361  _Message_queue_MP_Send_response_packet(
362    MESSAGE_QUEUE_MP_RECEIVE_RESPONSE,
363    the_proxy->Wait.id,
364    the_proxy
365  );
366}
367
368/*PAGE
369 *
370 *  _Message_queue_MP_Send_extract_proxy
371 *
372 */
373
374void _Message_queue_MP_Send_extract_proxy (
375  Thread_Control  *the_thread
376)
377{
378  _Message_queue_MP_Send_process_packet(
379    MESSAGE_QUEUE_MP_EXTRACT_PROXY,
380    the_thread->Wait.id,
381    (Objects_Name) 0,
382    the_thread->Object.id
383  );
384}
385
386/*PAGE
387 *
388 *  _Message_queue_MP_Get_packet
389 *
390 */
391
392Message_queue_MP_Packet *_Message_queue_MP_Get_packet ( void )
393{
394  return ( (Message_queue_MP_Packet *) _MPCI_Get_packet() );
395}
396
397/* end of file */
Note: See TracBrowser for help on using the repository browser.