source: rtems/cpukit/score/src/coremsgbroadcast.c @ bbd6d27a

5
Last change on this file since bbd6d27a was 8f96581, checked in by Sebastian Huber <sebastian.huber@…>, on 04/01/16 at 09:38:47

score: Rework MP thread queue callout support

The thread queue implementation was heavily reworked to support SMP.
This broke the multiprocessing support of the thread queues. This is
fixed by this patch.

A thread proxy is unblocked due to three reasons

1) timeout,
2) request satisfaction, and
3) extraction.

In case 1) no MPCI message must be sent. This is ensured via the
_Thread_queue_MP_callout_do_nothing() callout set during
_Thread_MP_Allocate_proxy().

In case 2) and 3) an MPCI message must be sent. In case we interrupt
the blocking operation during _Thread_queue_Enqueue_critical(), then
this message must be sent by the blocking thread. For this the new
fields Thread_Proxy_control::thread_queue_callout and
Thread_Proxy_control::thread_queue_id are used.

Delete the individual API MP callout types and use
Thread_queue_MP_callout throughout. This type is only defined in
multiprocessing configurations. Prefix the multiprocessing parameters
with mp_ to ease code review. Multiprocessing specific parameters are
optional due to use of a similar macro pattern. There is no overhead
for non-multiprocessing configurations.

  • Property mode set to 100644
File size: 1.6 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
24CORE_message_queue_Status _CORE_message_queue_Do_broadcast(
25  CORE_message_queue_Control *the_message_queue,
26  const void                 *buffer,
27  size_t                      size,
28#if defined(RTEMS_MULTIPROCESSING)
29  Thread_queue_MP_callout     mp_callout,
30  Objects_Id                  mp_id,
31#endif
32  uint32_t                   *count,
33  ISR_lock_Context           *lock_context
34)
35{
36  Thread_Control             *the_thread;
37  uint32_t                    number_broadcasted;
38
39  if ( size > the_message_queue->maximum_message_size ) {
40    _ISR_lock_ISR_enable( lock_context );
41    return CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE;
42  }
43
44  number_broadcasted = 0;
45
46  _CORE_message_queue_Acquire_critical( the_message_queue, lock_context );
47
48  while (
49    ( the_thread =
50      _CORE_message_queue_Dequeue_receiver(
51        the_message_queue,
52        buffer,
53        size,
54        mp_callout,
55        mp_id,
56        0,
57        lock_context
58      )
59    )
60  ) {
61    number_broadcasted += 1;
62
63    _CORE_message_queue_Acquire( the_message_queue, lock_context );
64  }
65
66  _CORE_message_queue_Release( the_message_queue, lock_context );
67
68  *count = number_broadcasted;
69  return CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL;
70}
Note: See TracBrowser for help on using the repository browser.