source: rtems/cpukit/score/src/coremsgbroadcast.c @ 7fa97181

Last change on this file since 7fa97181 was a6eef8b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:48

2003-09-04 Joel Sherrill <joel@…>

  • apiext.c, chain.c, coremsg.c, coremsgbroadcast.c, coremsgclose.c, coremsgflush.c, coremsgflushsupp.c, coremsgflushwait.c, coremsginsert.c, coremsgseize.c, coremsgsubmit.c, coremutex.c, coremutexflush.c, coremutexseize.c, coremutexsurrender.c, coresem.c, coresemflush.c, coresemseize.c, coresemsurrender.c, coretod.c, coretodset.c, coretodtickle.c, coretodtoseconds.c, coretodvalidate.c, heap.c, heapallocate.c, heapextend.c, heapfree.c, heapgetinfo.c, heapsizeofuserarea.c, heapwalk.c, interr.c, isr.c, mpci.c, object.c, objectallocate.c, objectallocatebyindex.c, objectclearname.c, objectcomparenameraw.c, objectcomparenamestring.c, objectcopynameraw.c, objectcopynamestring.c, objectextendinformation.c, objectfree.c, objectget.c, objectgetbyindex.c, objectgetisr.c, objectgetnext.c, objectgetnoprotection.c, objectinitializeinformation.c, objectmp.c, objectnametoid.c, objectshrinkinformation.c, thread.c, threadchangepriority.c, threadclearstate.c, threadclose.c, threadcreateidle.c, threaddelayended.c, threaddispatch.c, threadevaluatemode.c, threadget.c, threadhandler.c, threadidlebody.c, threadinitialize.c, threadloadenv.c, threadmp.c, threadq.c, threadqdequeue.c, threadqdequeuefifo.c, threadqdequeuepriority.c, threadqenqueue.c, threadqenqueuefifo.c, threadqenqueuepriority.c, threadqextract.c, threadqextractfifo.c, threadqextractpriority.c, threadqextractwithproxy.c, threadqfirst.c, threadqfirstfifo.c, threadqfirstpriority.c, threadqflush.c, threadqtimeout.c, threadready.c, threadreset.c, threadresettimeslice.c, threadrestart.c, threadresume.c, threadrotatequeue.c, threadsetpriority.c, threadsetstate.c, threadsettransient.c, threadstackallocate.c, threadstackfree.c, threadstart.c, threadstartmultitasking.c, threadsuspend.c, threadtickletimeslice.c, threadyieldprocessor.c, userext.c, watchdog.c, watchdogadjust.c, watchdoginsert.c, watchdogremove.c, watchdogtickle.c, wkspace.c: URL for license changed.
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  CORE Message Queue Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is the implementation of the CORE Message Queue Handler.
7 *  This core object provides task synchronization and communication functions
8 *  via messages passed to queue objects.
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <rtems/system.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/score/coremsg.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
32/*PAGE
33 *
34 *  _CORE_message_queue_Broadcast
35 *
36 *  This function sends a message for every thread waiting on the queue and
37 *  returns the number of threads made ready by the message.
38 *
39 *  Input parameters:
40 *    the_message_queue            - message is submitted to this message queue
41 *    buffer                       - pointer to message buffer
42 *    size                         - size in bytes of message to send
43 *    id                           - id of message queue
44 *    api_message_queue_mp_support - api specific mp support callout
45 *    count                        - area to store number of threads made ready
46 *
47 *  Output parameters:
48 *    count                         - number of threads made ready
49 *    CORE_MESSAGE_QUEUE_SUCCESSFUL - if successful
50 *    error code                    - if unsuccessful
51 */
52
53CORE_message_queue_Status _CORE_message_queue_Broadcast(
54  CORE_message_queue_Control                *the_message_queue,
55  void                                      *buffer,
56  unsigned32                                 size,
57  Objects_Id                                 id,
58  CORE_message_queue_API_mp_support_callout  api_message_queue_mp_support,
59  unsigned32                                *count
60)
61{
62  Thread_Control          *the_thread;
63  unsigned32               number_broadcasted;
64  Thread_Wait_information *waitp;
65  unsigned32               constrained_size;
66
67  /*
68   *  If there are pending messages, then there can't be threads
69   *  waiting for us to send them a message.
70   *
71   *  NOTE: This check is critical because threads can block on
72   *        send and receive and this ensures that we are broadcasting
73   *        the message to threads waiting to receive -- not to send.
74   */
75
76  if ( the_message_queue->number_of_pending_messages != 0 ) {
77    *count = 0;
78    return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
79  }
80
81  /*
82   *  There must be no pending messages if there is a thread waiting to
83   *  receive a message.
84   */
85
86  number_broadcasted = 0;
87  while ((the_thread = _Thread_queue_Dequeue(&the_message_queue->Wait_queue))) {
88    waitp = &the_thread->Wait;
89    number_broadcasted += 1;
90
91    constrained_size = size;
92    if ( size > the_message_queue->maximum_message_size )
93        constrained_size = the_message_queue->maximum_message_size;
94
95    _CORE_message_queue_Copy_buffer(
96      buffer,
97      waitp->return_argument,
98      constrained_size
99    );
100
101    *(unsigned32 *)the_thread->Wait.return_argument_1 = size;
102
103#if defined(RTEMS_MULTIPROCESSING)
104    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
105      (*api_message_queue_mp_support) ( the_thread, id );
106#endif
107
108  }
109  *count = number_broadcasted;
110  return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
111}
112
Note: See TracBrowser for help on using the repository browser.