source: rtems/cpukit/score/src/threadq.c @ 0a97ba5b

5
Last change on this file since 0a97ba5b 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: 2.4 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Thread Queue Initialize
5 *  @ingroup ScoreThreadQ
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/score/threadqimpl.h>
22#include <rtems/score/rbtreeimpl.h>
23#include <rtems/score/threadimpl.h>
24
25#if HAVE_STRUCT__THREAD_QUEUE_QUEUE
26
27RTEMS_STATIC_ASSERT(
28  offsetof( Thread_queue_Syslock_queue, Queue.heads )
29    == offsetof( struct _Thread_queue_Queue, _heads ),
30  THREAD_QUEUE_SYSLOCK_QUEUE_HEADS
31);
32
33RTEMS_STATIC_ASSERT(
34#if defined(RTEMS_SMP)
35  offsetof( Thread_queue_Syslock_queue, Queue.Lock.next_ticket )
36#else
37  offsetof( Thread_queue_Syslock_queue, reserved[ 0 ] )
38#endif
39    == offsetof( struct _Thread_queue_Queue, _Lock._next_ticket ),
40  THREAD_QUEUE_SYSLOCK_QUEUE_NEXT_TICKET
41);
42
43RTEMS_STATIC_ASSERT(
44#if defined(RTEMS_SMP)
45  offsetof( Thread_queue_Syslock_queue, Queue.Lock.now_serving )
46#else
47  offsetof( Thread_queue_Syslock_queue, reserved[ 1 ] )
48#endif
49    == offsetof( struct _Thread_queue_Queue, _Lock._now_serving ),
50  THREAD_QUEUE_SYSLOCK_QUEUE_NOW_SERVING
51);
52
53RTEMS_STATIC_ASSERT(
54  sizeof( Thread_queue_Syslock_queue )
55    == sizeof( struct _Thread_queue_Queue ),
56  THREAD_QUEUE_SYSLOCK_QUEUE_SIZE
57);
58
59#endif /* HAVE_STRUCT__THREAD_QUEUE_QUEUE */
60
61RBTree_Compare_result _Thread_queue_Compare_priority(
62  const RBTree_Node *left,
63  const RBTree_Node *right
64)
65{
66  const Thread_Control *left_thread;
67  const Thread_Control *right_thread;
68  Priority_Control      left_prio;
69  Priority_Control      right_prio;
70
71  left_thread = THREAD_RBTREE_NODE_TO_THREAD( left );
72  right_thread = THREAD_RBTREE_NODE_TO_THREAD( right );
73  left_prio = left_thread->current_priority;
74  right_prio = right_thread->current_priority;
75
76  /*
77   * SuperCore priorities use lower numbers to indicate greater importance.
78   */
79  return ( left_prio > right_prio ) - ( left_prio < right_prio );
80}
81
82void _Thread_queue_Initialize( Thread_queue_Control *the_thread_queue )
83{
84  _Thread_queue_Queue_initialize( &the_thread_queue->Queue );
85#if defined(RTEMS_SMP)
86  _SMP_lock_Stats_initialize( &the_thread_queue->Lock_stats, "Thread Queue" );
87#endif
88}
89
90#if defined(RTEMS_MULTIPROCESSING)
91void _Thread_queue_MP_callout_do_nothing(
92  Thread_Control *the_proxy,
93  Objects_Id      mp_id
94)
95{
96  /* Do nothing */
97}
98#endif
Note: See TracBrowser for help on using the repository browser.