source: rtems/cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h @ 238629f

4.115
Last change on this file since 238629f was 238629f, checked in by Joel Sherrill <joel.sherrill@…>, on May 19, 2014 at 8:26:55 PM

Add SMP Priority Scheduler with Affinity

This scheduler attempts to account for needed thread migrations caused
as a side-effect of a thread state, affinity, or priority change operation.

This scheduler has its own allocate_processor handler named
_Scheduler_SMP_Allocate_processor_exact() because
_Scheduler_SMP_Allocate_processor() attempts to prevent an executing
thread from moving off its current CPU without considering affinity.
Without this, the scheduler makes all the right decisions and then
they are discarded at the end.

==Side Effects of Adding This Scheduler==

Added Thread_Control * parameter to Scheduler_SMP_Get_highest_ready type
so methods looking for the highest ready thread can filter by the processor
on which the thread blocking resides. This allows affinity to be considered.
Simple Priority SMP and Priority SMP ignore this parameter.

+ Added get_lowest_scheduled argument to _Scheduler_SMP_Enqueue_ordered().

+ Added allocate_processor argument to the following methods:

  • _Scheduler_SMP_Block()
  • _Scheduler_SMP_Enqueue_scheduled_ordered()
  • _Scheduler_SMP_Enqueue_scheduled_ordered()

+ schedulerprioritysmpimpl.h is a new file with prototypes for methods

which were formerly static in schedulerprioritysmp.c but now need to
be public to be shared with this scheduler.

NOTE:

_Scheduler_SMP_Get_lowest_ready() appears to have a path which would
allow it to return a NULL. Previously, _Scheduler_SMP_Enqueue_ordered()
would have asserted on it. If it cannot return a NULL,
_Scheduler_SMP_Get_lowest_ready() should have an assertions.

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSchedulerPriorityAffinitySMP
5 *
6 * @brief Deterministic Priority Affinity SMP Scheduler API
7 */
8
9/*
10 *  COPYRIGHT (c) 2014.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H
19#define _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H
20
21#include <rtems/score/scheduler.h>
22#include <rtems/score/schedulerpriority.h>
23#include <rtems/score/schedulersmp.h>
24#include <rtems/score/schedulerprioritysmp.h>
25#include <rtems/score/cpuset.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31/**
32 * @defgroup ScoreSchedulerPriorityAffinitySMP Deterministic Priority Affinity SMP Scheduler
33 *
34 * @ingroup ScoreSchedulerPrioritySMP
35 *
36 * This is an extension of the Deterministic Priority SMP Scheduler. which
37 * is an implementation of the global fixed priority scheduler (G-FP).
38 * It adds thread to core affinity support.
39 *
40 * @note This is the first iteration of this scheduler. It currently tracks
41 *       the requested affinity to exercise the Scheduler Framework but it
42 *       does not honor that affinity in assigning threads to cores. This
43 *       will be added in a subsequent revision.
44 * @{
45 */
46
47/**
48 * @brief Entry points for the Deterministic Priority Affinity SMP Scheduler.
49 */
50#define SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS \
51  { \
52    _Scheduler_priority_SMP_Initialize, \
53    _Scheduler_default_Schedule, \
54    _Scheduler_priority_SMP_Yield, \
55    _Scheduler_priority_affinity_SMP_Block, \
56    _Scheduler_priority_affinity_SMP_Unblock, \
57    _Scheduler_priority_affinity_SMP_Change_priority, \
58    _Scheduler_priority_affinity_SMP_Node_initialize, \
59    _Scheduler_default_Node_destroy, \
60    _Scheduler_priority_SMP_Update_priority, \
61    _Scheduler_priority_Priority_compare, \
62    _Scheduler_default_Release_job, \
63    _Scheduler_default_Tick, \
64    _Scheduler_SMP_Start_idle, \
65    _Scheduler_priority_affinity_SMP_Get_affinity, \
66    _Scheduler_priority_affinity_SMP_Set_affinity \
67  }
68
69/**
70 *  @brief Initializes per thread scheduler information
71 *
72 *  This routine allocates @a thread->scheduler.
73 *
74 *  @param[in] scheduler points to the scheduler specific information.
75 *  @param[in] thread is the thread the scheduler is allocating
76 *             management memory for.
77 */
78void _Scheduler_priority_affinity_SMP_Node_initialize(
79  const Scheduler_Control *scheduler,
80  Thread_Control          *thread
81);
82
83/**
84 * @brief SMP Priority Affinity Scheduler Block Operation
85 *
86 * This method is the block operation for this scheduler.
87 *
88 * @param[in] scheduler is the scheduler instance information
89 * @param[in] thread is the thread to block
90 */
91void _Scheduler_priority_affinity_SMP_Block(
92  const Scheduler_Control *scheduler,
93  Thread_Control          *thread
94);
95
96/**
97 * @brief SMP Priority Affinity Scheduler Unblock Operation
98 *
99 * This method is the unblock operation for this scheduler.
100 *
101 * @param[in] scheduler is the scheduler instance information
102 * @param[in] thread is the thread to unblock
103 */
104void _Scheduler_priority_affinity_SMP_Unblock(
105  const Scheduler_Control *scheduler,
106  Thread_Control          *thread
107);
108
109/**
110 * @brief Get affinity for the priority affinity SMP scheduler.
111 *
112 * @param[in] scheduler The scheduler of the thread.
113 * @param[in] thread The associated thread.
114 * @param[in] cpusetsize The size of the cpuset.
115 * @param[in,out] cpuset The associated affinity set.
116 *
117 * @retval 0 Successfully got cpuset
118 * @retval -1 The cpusetsize is invalid for the system
119 */
120bool _Scheduler_priority_affinity_SMP_Get_affinity(
121  const Scheduler_Control *scheduler,
122  Thread_Control          *thread,
123  size_t                   cpusetsize,
124  cpu_set_t               *cpuset
125);
126
127/**
128 * @brief Change priority for the priority affinity SMP scheduler.
129 *
130 * @param[in] scheduler The scheduler of the thread.
131 * @param[in] thread The associated thread.
132 * @param[in] new_priority The new priority for the thread.
133 * @param[in] prepend_it Append or prepend the thread to its priority FIFO.
134 */
135void _Scheduler_priority_affinity_SMP_Change_priority(
136  const Scheduler_Control *scheduler,
137  Thread_Control          *the_thread,
138  Priority_Control         new_priority,
139  bool                     prepend_it
140);
141
142/**
143 * @brief Set affinity for the priority affinity SMP scheduler.
144 *
145 * @param[in] scheduler The scheduler of the thread.
146 * @param[in] thread The associated thread.
147 * @param[in] cpusetsize The size of the cpuset.
148 * @param[in] cpuset Affinity new affinity set.
149 *
150 * @retval true if successful
151 * @retval false if unsuccessful
152 */
153bool _Scheduler_priority_affinity_SMP_Set_affinity(
154  const Scheduler_Control *scheduler,
155  Thread_Control          *thread,
156  size_t                   cpusetsize,
157  const cpu_set_t         *cpuset
158);
159
160/**
161 * @brief Scheduler node specialization for Deterministic Priority Affinity SMP
162 * schedulers.
163 *
164 * This is a per thread structure.
165 */
166typedef struct {
167  /**
168   * @brief SMP priority scheduler node.
169   */
170  Scheduler_priority_SMP_Node Base;
171
172  /**
173   * Structure containing affinity set data and size
174   */
175  CPU_set_Control Affinity;
176} Scheduler_priority_affinity_SMP_Node;
177
178/** @} */
179
180#ifdef __cplusplus
181}
182#endif /* __cplusplus */
183
184#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H */
Note: See TracBrowser for help on using the repository browser.