source: rtems/cpukit/rtems/src/msgqbroadcast.c @ f773c012

4.104.114.95
Last change on this file since f773c012 was f773c012, checked in by Joel Sherrill <joel.sherrill@…>, on 08/05/08 at 13:32:39

2008-08-04 Sebastian Huber <sebastian.huber@…>

  • rtems/include/rtems/rtems/sem.h, rtems/src/semobtain.c: Changed option set type to rtems_option.
  • score/src/objectgetinfo.c: Check return value of _Objects_API_maximum_class().
  • libmisc/monitor/mon-mpci.c, libmisc/monitor/monitor.h, rtems/include/rtems/rtems/message.h, rtems/src/msgmp.c, rtems/src/msgqallocate.c, rtems/src/msgqbroadcast.c, rtems/src/msgqcreate.c, rtems/src/msgqreceive.c, rtems/src/msgqsend.c, rtems/src/msgqurgent.c, score/include/rtems/score/coremsg.h, score/include/rtems/score/mpci.h, score/include/rtems/score/thread.h, score/inline/rtems/score/coremsg.inl, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c: Removed parameters of _Message_queue_Allocate(). Changed option set type to rtems_option. Changed type of maximum message and packet size to size_t. Changed the input buffer type for message send functions to "const void *". Changed the pointer to the second return argument in the thread wait information to a union. This union can contain a pointer to an immutable or a mutable object. This is somewhat fragile. An alternative would be to add a third pointer for immutable objects, but this would increase the structure size.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  Message Queue Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-2007.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/sysstate.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/coremsg.h>
24#include <rtems/score/object.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#if defined(RTEMS_MULTIPROCESSING)
29#include <rtems/score/mpci.h>
30#endif
31#include <rtems/rtems/status.h>
32#include <rtems/rtems/attr.h>
33#include <rtems/rtems/message.h>
34#include <rtems/rtems/options.h>
35#include <rtems/rtems/support.h>
36
37/*PAGE
38 *
39 *  rtems_message_queue_broadcast
40 *
41 *  This directive sends a message for every thread waiting on the queue
42 *  designated by id.
43 *
44 *  Input parameters:
45 *    id     - pointer to message queue
46 *    buffer - pointer to message buffer
47 *    size   - size of message to broadcast
48 *    count  - pointer to area to store number of threads made ready
49 *
50 *  Output parameters:
51 *    count             - number of threads made ready
52 *    RTEMS_SUCCESSFUL  - if successful
53 *    error code        - if unsuccessful
54 */
55
56rtems_status_code rtems_message_queue_broadcast(
57  Objects_Id            id,
58  const void           *buffer,
59  size_t                size,
60  uint32_t             *count
61)
62{
63  register Message_queue_Control *the_message_queue;
64  Objects_Locations               location;
65  CORE_message_queue_Status       core_status;
66
67  if ( !buffer )
68    return RTEMS_INVALID_ADDRESS;
69
70  if ( !count )
71    return RTEMS_INVALID_ADDRESS;
72
73  the_message_queue = _Message_queue_Get( id, &location );
74  switch ( location ) {
75
76    case OBJECTS_LOCAL:
77      core_status = _CORE_message_queue_Broadcast(
78                      &the_message_queue->message_queue,
79                      buffer,
80                      size,
81                      id,
82                      #if defined(RTEMS_MULTIPROCESSING)
83                        _Message_queue_Core_message_queue_mp_support,
84                      #else
85                        NULL,
86                      #endif
87                      count
88                    );
89
90      _Thread_Enable_dispatch();
91      return
92        _Message_queue_Translate_core_message_queue_return_code( core_status );
93
94#if defined(RTEMS_MULTIPROCESSING)
95    case OBJECTS_REMOTE:
96      _Thread_Executing->Wait.return_argument = count;
97
98      return
99        _Message_queue_MP_Send_request_packet(
100          MESSAGE_QUEUE_MP_BROADCAST_REQUEST,
101          id,
102          buffer,
103          &size,
104          0,                               /* option_set not used */
105          MPCI_DEFAULT_TIMEOUT
106        );
107#endif
108
109    case OBJECTS_ERROR:
110      break;
111  }
112  return RTEMS_INVALID_ID;
113}
Note: See TracBrowser for help on using the repository browser.