source: rtems/cpukit/rtems/src/msgqbroadcast.c @ 8f96581

Last change on this file since 8f96581 was 8f96581, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 1, 2016 at 9:38:47 AM

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: 2.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Broadcast Message Queue
5 *  @ingroup ClassicMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
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/system.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/coremsgimpl.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/wkspace.h>
27#include <rtems/rtems/status.h>
28#include <rtems/rtems/attrimpl.h>
29#include <rtems/rtems/messageimpl.h>
30#include <rtems/rtems/options.h>
31#include <rtems/rtems/support.h>
32
33rtems_status_code rtems_message_queue_broadcast(
34  rtems_id    id,
35  const void *buffer,
36  size_t      size,
37  uint32_t   *count
38)
39{
40  Message_queue_Control          *the_message_queue;
41  Objects_Locations               location;
42  CORE_message_queue_Status       core_status;
43  ISR_lock_Context                lock_context;
44
45  if ( !buffer )
46    return RTEMS_INVALID_ADDRESS;
47
48  if ( !count )
49    return RTEMS_INVALID_ADDRESS;
50
51  the_message_queue = _Message_queue_Get_interrupt_disable(
52    id,
53    &location,
54    &lock_context
55  );
56  switch ( location ) {
57
58    case OBJECTS_LOCAL:
59      core_status = _CORE_message_queue_Broadcast(
60                      &the_message_queue->message_queue,
61                      buffer,
62                      size,
63                      _Message_queue_Core_message_queue_mp_support,
64                      id,
65                      count,
66                      &lock_context
67                    );
68      return
69        _Message_queue_Translate_core_message_queue_return_code( core_status );
70
71#if defined(RTEMS_MULTIPROCESSING)
72    case OBJECTS_REMOTE:
73      _Thread_Executing->Wait.return_argument = count;
74
75      return
76        _Message_queue_MP_Send_request_packet(
77          MESSAGE_QUEUE_MP_BROADCAST_REQUEST,
78          id,
79          buffer,
80          &size,
81          0,                               /* option_set not used */
82          MPCI_DEFAULT_TIMEOUT
83        );
84#endif
85
86    case OBJECTS_ERROR:
87      break;
88  }
89  return RTEMS_INVALID_ID;
90}
Note: See TracBrowser for help on using the repository browser.