source: rtems/cpukit/score/src/coremsgbroadcast.c @ 2548d14

5
Last change on this file since 2548d14 was e41308ea, checked in by Sebastian Huber <sebastian.huber@…>, on 08/22/16 at 08:58:34

score: Introduce Thread_queue_Lock_context

Introduce Thread_queue_Lock_context to contain the context necessary for
thread queue lock and thread wait lock acquire/release operations to
reduce the Thread_Control size.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Broadcast a Message to the Message Queue
5 *  @ingroup ScoreMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/coremsgimpl.h>
22#include <rtems/score/objectimpl.h>
23
24Status_Control _CORE_message_queue_Broadcast(
25  CORE_message_queue_Control *the_message_queue,
26  const void                 *buffer,
27  size_t                      size,
28  uint32_t                   *count,
29  Thread_queue_Context       *queue_context
30)
31{
32  Thread_Control             *the_thread;
33  uint32_t                    number_broadcasted;
34
35  if ( size > the_message_queue->maximum_message_size ) {
36    _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
37    return STATUS_MESSAGE_INVALID_SIZE;
38  }
39
40  number_broadcasted = 0;
41
42  _CORE_message_queue_Acquire_critical( the_message_queue, queue_context );
43
44  while (
45    ( the_thread =
46      _CORE_message_queue_Dequeue_receiver(
47        the_message_queue,
48        buffer,
49        size,
50        0,
51        queue_context
52      )
53    )
54  ) {
55    number_broadcasted += 1;
56
57    _CORE_message_queue_Acquire( the_message_queue, queue_context );
58  }
59
60  _CORE_message_queue_Release( the_message_queue, queue_context );
61
62  *count = number_broadcasted;
63  return STATUS_SUCCESSFUL;
64}
Note: See TracBrowser for help on using the repository browser.