source: rtems/cpukit/include/rtems/score/schedulerpriorityaffinitysmp.h @ 21275b58

Last change on this file since 21275b58 was 7097962, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 29, 2018 at 7:43:44 AM

score: Add thread pin/unpin support

Add support to temporarily pin a thread to its current processor. This
may be used to access per-processor data structures in critical sections
with enabled thread dispatching, e.g. a pinned thread is allowed to
block.

Update #3508.

  • Property mode set to 100644
File size: 5.2 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
26#include <sys/cpuset.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
32/**
33 * @defgroup ScoreSchedulerPriorityAffinitySMP Deterministic Priority Affinity SMP Scheduler
34 *
35 * @ingroup ScoreSchedulerPrioritySMP
36 *
37 * This is an extension of the Deterministic Priority SMP Scheduler. which
38 * is an implementation of the global fixed priority scheduler (G-FP).
39 * It adds thread to core affinity support.
40 *
41 * @note This is the first iteration of this scheduler. It currently tracks
42 *       the requested affinity to exercise the Scheduler Framework but it
43 *       does not honor that affinity in assigning threads to cores. This
44 *       will be added in a subsequent revision.
45 * @{
46 */
47
48/**
49 * @brief Entry points for the Deterministic Priority Affinity SMP Scheduler.
50 */
51#define SCHEDULER_PRIORITY_AFFINITY_SMP_ENTRY_POINTS \
52  { \
53    _Scheduler_priority_SMP_Initialize, \
54    _Scheduler_default_Schedule, \
55    _Scheduler_priority_SMP_Yield, \
56    _Scheduler_priority_affinity_SMP_Block, \
57    _Scheduler_priority_affinity_SMP_Unblock, \
58    _Scheduler_priority_affinity_SMP_Update_priority, \
59    _Scheduler_default_Map_priority, \
60    _Scheduler_default_Unmap_priority, \
61    _Scheduler_priority_affinity_SMP_Ask_for_help, \
62    _Scheduler_priority_affinity_SMP_Reconsider_help_request, \
63    _Scheduler_priority_affinity_SMP_Withdraw_node, \
64    _Scheduler_default_Pin_or_unpin, \
65    _Scheduler_default_Pin_or_unpin, \
66    _Scheduler_priority_affinity_SMP_Add_processor, \
67    _Scheduler_priority_affinity_SMP_Remove_processor, \
68    _Scheduler_priority_affinity_SMP_Node_initialize, \
69    _Scheduler_default_Node_destroy, \
70    _Scheduler_default_Release_job, \
71    _Scheduler_default_Cancel_job, \
72    _Scheduler_default_Tick, \
73    _Scheduler_SMP_Start_idle, \
74    _Scheduler_priority_affinity_SMP_Set_affinity \
75  }
76
77/**
78 *  @brief Initializes per thread scheduler information
79 *
80 *  This routine allocates @a thread->scheduler.
81 *
82 *  @param[in] scheduler points to the scheduler specific information.
83 *  @param[in] node is the node the scheduler is allocating
84 *             management memory for.
85 *  @param[in] the_thread the thread of the node.
86 *  @param[in] priority is the thread priority.
87 */
88void _Scheduler_priority_affinity_SMP_Node_initialize(
89  const Scheduler_Control *scheduler,
90  Scheduler_Node          *node,
91  Thread_Control          *the_thread,
92  Priority_Control         priority
93);
94
95void _Scheduler_priority_affinity_SMP_Block(
96  const Scheduler_Control *scheduler,
97  Thread_Control          *thread,
98  Scheduler_Node          *node
99);
100
101void _Scheduler_priority_affinity_SMP_Unblock(
102  const Scheduler_Control *scheduler,
103  Thread_Control          *thread,
104  Scheduler_Node          *node
105);
106
107void _Scheduler_priority_affinity_SMP_Update_priority(
108  const Scheduler_Control *scheduler,
109  Thread_Control          *the_thread,
110  Scheduler_Node          *node
111);
112
113bool _Scheduler_priority_affinity_SMP_Ask_for_help(
114  const Scheduler_Control *scheduler,
115  Thread_Control          *the_thread,
116  Scheduler_Node          *node
117);
118
119void _Scheduler_priority_affinity_SMP_Reconsider_help_request(
120  const Scheduler_Control *scheduler,
121  Thread_Control          *the_thread,
122  Scheduler_Node          *node
123);
124
125void _Scheduler_priority_affinity_SMP_Withdraw_node(
126  const Scheduler_Control *scheduler,
127  Thread_Control          *the_thread,
128  Scheduler_Node          *node,
129  Thread_Scheduler_state   next_state
130);
131
132void _Scheduler_priority_affinity_SMP_Add_processor(
133  const Scheduler_Control *scheduler,
134  Thread_Control          *idle
135);
136
137Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor(
138  const Scheduler_Control *scheduler,
139  struct Per_CPU_Control  *cpu
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] affinity The new affinity set.
148 *
149 * @retval true if successful
150 * @retval false if unsuccessful
151 */
152bool _Scheduler_priority_affinity_SMP_Set_affinity(
153  const Scheduler_Control *scheduler,
154  Thread_Control          *thread,
155  Scheduler_Node          *node,
156  const Processor_mask    *affinity
157);
158
159/**
160 * @brief Scheduler node specialization for Deterministic Priority Affinity SMP
161 * schedulers.
162 *
163 * This is a per thread structure.
164 */
165typedef struct {
166  /**
167   * @brief SMP priority scheduler node.
168   */
169  Scheduler_priority_SMP_Node Base;
170
171  /**
172   * @brief The thread processor affinity set.
173   */
174  Processor_mask Affinity;
175} Scheduler_priority_affinity_SMP_Node;
176
177/** @} */
178
179#ifdef __cplusplus
180}
181#endif /* __cplusplus */
182
183#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYAFFINITYSMP_H */
Note: See TracBrowser for help on using the repository browser.