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