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

5
Last change on this file since 21275b58 was 7097962, checked in by Sebastian Huber <sebastian.huber@…>, on 08/29/18 at 07:43:44

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.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief EDF SMP Scheduler API
5 *
6 * @ingroup ScoreSchedulerSMPEDF
7 */
8
9/*
10 * Copyright (c) 2017, 2018 embedded brains GmbH.
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#ifndef _RTEMS_SCORE_SCHEDULEREDFSMP_H
18#define _RTEMS_SCORE_SCHEDULEREDFSMP_H
19
20#include <rtems/score/scheduler.h>
21#include <rtems/score/scheduleredf.h>
22#include <rtems/score/schedulersmp.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/**
29 * @defgroup ScoreSchedulerSMPEDF EDF Priority SMP Scheduler
30 *
31 * @ingroup ScoreSchedulerSMP
32 *
33 * @{
34 */
35
36typedef struct {
37  Scheduler_SMP_Node Base;
38
39  /**
40   * @brief Generation number to ensure FIFO/LIFO order for threads of the same
41   * priority across different ready queues.
42   */
43  int64_t generation;
44
45  /**
46   * @brief The ready queue index depending on the processor affinity and
47   * pinning of the thread.
48   *
49   * The ready queue index zero is used for threads with a one-to-all thread
50   * processor affinity.  Threads with a one-to-one processor affinity use the
51   * processor index plus one as the ready queue index.
52   */
53  uint8_t ready_queue_index;
54
55  /**
56   * @brief Ready queue index according to thread affinity.
57   */
58  uint8_t affinity_ready_queue_index;
59
60  /**
61   * @brief Ready queue index according to thread pinning.
62   */
63  uint8_t pinning_ready_queue_index;
64} Scheduler_EDF_SMP_Node;
65
66typedef struct {
67  /**
68   * @brief Chain node for Scheduler_SMP_Context::Affine_queues.
69   */
70  Chain_Node Node;
71
72  /**
73   * @brief The ready threads of the corresponding affinity.
74   */
75  RBTree_Control Queue;
76
77  /**
78   * @brief The scheduled thread of the corresponding processor.
79   */
80  Scheduler_EDF_SMP_Node *scheduled;
81} Scheduler_EDF_SMP_Ready_queue;
82
83typedef struct {
84  Scheduler_SMP_Context Base;
85
86  /**
87   * @brief Current generation for LIFO (index 0) and FIFO (index 1) ordering.
88   */
89  int64_t generations[ 2 ];
90
91  /**
92   * @brief Chain of ready queues with affine threads to determine the highest
93   * priority ready thread.
94   */
95  Chain_Control Affine_queues;
96
97  /**
98   * @brief A table with ready queues.
99   *
100   * The index zero queue is used for threads with a one-to-all processor
101   * affinity.  Index one corresponds to processor index zero, and so on.
102   */
103  Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ];
104} Scheduler_EDF_SMP_Context;
105
106#define SCHEDULER_EDF_SMP_ENTRY_POINTS \
107  { \
108    _Scheduler_EDF_SMP_Initialize, \
109    _Scheduler_default_Schedule, \
110    _Scheduler_EDF_SMP_Yield, \
111    _Scheduler_EDF_SMP_Block, \
112    _Scheduler_EDF_SMP_Unblock, \
113    _Scheduler_EDF_SMP_Update_priority, \
114    _Scheduler_EDF_Map_priority, \
115    _Scheduler_EDF_Unmap_priority, \
116    _Scheduler_EDF_SMP_Ask_for_help, \
117    _Scheduler_EDF_SMP_Reconsider_help_request, \
118    _Scheduler_EDF_SMP_Withdraw_node, \
119    _Scheduler_EDF_SMP_Pin, \
120    _Scheduler_EDF_SMP_Unpin, \
121    _Scheduler_EDF_SMP_Add_processor, \
122    _Scheduler_EDF_SMP_Remove_processor, \
123    _Scheduler_EDF_SMP_Node_initialize, \
124    _Scheduler_default_Node_destroy, \
125    _Scheduler_EDF_Release_job, \
126    _Scheduler_EDF_Cancel_job, \
127    _Scheduler_default_Tick, \
128    _Scheduler_EDF_SMP_Start_idle, \
129    _Scheduler_EDF_SMP_Set_affinity \
130  }
131
132void _Scheduler_EDF_SMP_Initialize( const Scheduler_Control *scheduler );
133
134void _Scheduler_EDF_SMP_Node_initialize(
135  const Scheduler_Control *scheduler,
136  Scheduler_Node          *node,
137  Thread_Control          *the_thread,
138  Priority_Control         priority
139);
140
141void _Scheduler_EDF_SMP_Block(
142  const Scheduler_Control *scheduler,
143  Thread_Control          *thread,
144  Scheduler_Node          *node
145);
146
147void _Scheduler_EDF_SMP_Unblock(
148  const Scheduler_Control *scheduler,
149  Thread_Control          *thread,
150  Scheduler_Node          *node
151);
152
153void _Scheduler_EDF_SMP_Update_priority(
154  const Scheduler_Control *scheduler,
155  Thread_Control          *the_thread,
156  Scheduler_Node          *node
157);
158
159bool _Scheduler_EDF_SMP_Ask_for_help(
160  const Scheduler_Control *scheduler,
161  Thread_Control          *the_thread,
162  Scheduler_Node          *node
163);
164
165void _Scheduler_EDF_SMP_Reconsider_help_request(
166  const Scheduler_Control *scheduler,
167  Thread_Control          *the_thread,
168  Scheduler_Node          *node
169);
170
171void _Scheduler_EDF_SMP_Withdraw_node(
172  const Scheduler_Control *scheduler,
173  Thread_Control          *the_thread,
174  Scheduler_Node          *node,
175  Thread_Scheduler_state   next_state
176);
177
178void _Scheduler_EDF_SMP_Pin(
179  const Scheduler_Control *scheduler,
180  Thread_Control          *the_thread,
181  Scheduler_Node          *node,
182  struct Per_CPU_Control  *cpu
183);
184
185void _Scheduler_EDF_SMP_Unpin(
186  const Scheduler_Control *scheduler,
187  Thread_Control          *the_thread,
188  Scheduler_Node          *node,
189  struct Per_CPU_Control  *cpu
190);
191
192void _Scheduler_EDF_SMP_Add_processor(
193  const Scheduler_Control *scheduler,
194  Thread_Control          *idle
195);
196
197Thread_Control *_Scheduler_EDF_SMP_Remove_processor(
198  const Scheduler_Control *scheduler,
199  struct Per_CPU_Control  *cpu
200);
201
202void _Scheduler_EDF_SMP_Yield(
203  const Scheduler_Control *scheduler,
204  Thread_Control          *thread,
205  Scheduler_Node          *node
206);
207
208void _Scheduler_EDF_SMP_Start_idle(
209  const Scheduler_Control *scheduler,
210  Thread_Control          *idle,
211  struct Per_CPU_Control  *cpu
212);
213
214bool _Scheduler_EDF_SMP_Set_affinity(
215  const Scheduler_Control *scheduler,
216  Thread_Control          *thread,
217  Scheduler_Node          *node,
218  const Processor_mask    *affinity
219);
220
221/** @} */
222
223#ifdef __cplusplus
224}
225#endif
226
227#endif /* _RTEMS_SCORE_SCHEDULEREDFSMP_H */
Note: See TracBrowser for help on using the repository browser.