source: rtems/cpukit/score/include/rtems/score/scheduleredfsmp.h @ 34487537

5
Last change on this file since 34487537 was 34487537, checked in by Sebastian Huber <sebastian.huber@…>, on 07/04/17 at 07:57:30

score: Add simple affinity support to EDF SMP

Update #3059.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief EDF SMP Scheduler API
5 *
6 * @ingroup ScoreSchedulerSMPEDF
7 */
8
9/*
10 * Copyright (c) 2017 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 of the thread.
47   *
48   * The ready queue index zero is used for threads with a one-to-all thread
49   * processor affinity.  Threads with a one-to-one processor affinity use the
50   * processor index plus one as the ready queue index.
51   */
52  uint32_t ready_queue_index;
53} Scheduler_EDF_SMP_Node;
54
55typedef struct {
56  /**
57   * @brief Chain node for Scheduler_SMP_Context::Affine_queues.
58   */
59  Chain_Node Node;
60
61  /**
62   * @brief The ready threads of the corresponding affinity.
63   */
64  RBTree_Control Queue;
65
66  /**
67   * @brief The scheduled thread of the corresponding processor.
68   */
69  Scheduler_EDF_SMP_Node *scheduled;
70} Scheduler_EDF_SMP_Ready_queue;
71
72typedef struct {
73  Scheduler_SMP_Context Base;
74
75  /**
76   * @brief Current generation for FIFO/LIFO ordering.
77   */
78  int64_t generations[ 2 ];
79
80  /**
81   * @brief Chain of ready queues with affine threads to determine the highest
82   * priority ready thread.
83   */
84  Chain_Control Affine_queues;
85
86  /**
87   * @brief A table with ready queues.
88   *
89   * The index zero queue is used for threads with a one-to-all processor
90   * affinity.  Index one corresponds to processor index zero, and so on.
91   */
92  Scheduler_EDF_SMP_Ready_queue Ready[ RTEMS_ZERO_LENGTH_ARRAY ];
93} Scheduler_EDF_SMP_Context;
94
95#define SCHEDULER_EDF_SMP_ENTRY_POINTS \
96  { \
97    _Scheduler_EDF_SMP_Initialize, \
98    _Scheduler_default_Schedule, \
99    _Scheduler_EDF_SMP_Yield, \
100    _Scheduler_EDF_SMP_Block, \
101    _Scheduler_EDF_SMP_Unblock, \
102    _Scheduler_EDF_SMP_Update_priority, \
103    _Scheduler_EDF_Map_priority, \
104    _Scheduler_EDF_Unmap_priority, \
105    _Scheduler_EDF_SMP_Ask_for_help, \
106    _Scheduler_EDF_SMP_Reconsider_help_request, \
107    _Scheduler_EDF_SMP_Withdraw_node, \
108    _Scheduler_EDF_SMP_Add_processor, \
109    _Scheduler_EDF_SMP_Remove_processor, \
110    _Scheduler_EDF_SMP_Node_initialize, \
111    _Scheduler_default_Node_destroy, \
112    _Scheduler_EDF_Release_job, \
113    _Scheduler_EDF_Cancel_job, \
114    _Scheduler_default_Tick, \
115    _Scheduler_EDF_SMP_Start_idle, \
116    _Scheduler_EDF_SMP_Set_affinity \
117  }
118
119void _Scheduler_EDF_SMP_Initialize( const Scheduler_Control *scheduler );
120
121void _Scheduler_EDF_SMP_Node_initialize(
122  const Scheduler_Control *scheduler,
123  Scheduler_Node          *node,
124  Thread_Control          *the_thread,
125  Priority_Control         priority
126);
127
128void _Scheduler_EDF_SMP_Block(
129  const Scheduler_Control *scheduler,
130  Thread_Control          *thread,
131  Scheduler_Node          *node
132);
133
134void _Scheduler_EDF_SMP_Unblock(
135  const Scheduler_Control *scheduler,
136  Thread_Control          *thread,
137  Scheduler_Node          *node
138);
139
140void _Scheduler_EDF_SMP_Update_priority(
141  const Scheduler_Control *scheduler,
142  Thread_Control          *the_thread,
143  Scheduler_Node          *node
144);
145
146bool _Scheduler_EDF_SMP_Ask_for_help(
147  const Scheduler_Control *scheduler,
148  Thread_Control          *the_thread,
149  Scheduler_Node          *node
150);
151
152void _Scheduler_EDF_SMP_Reconsider_help_request(
153  const Scheduler_Control *scheduler,
154  Thread_Control          *the_thread,
155  Scheduler_Node          *node
156);
157
158void _Scheduler_EDF_SMP_Withdraw_node(
159  const Scheduler_Control *scheduler,
160  Thread_Control          *the_thread,
161  Scheduler_Node          *node,
162  Thread_Scheduler_state   next_state
163);
164
165void _Scheduler_EDF_SMP_Add_processor(
166  const Scheduler_Control *scheduler,
167  Thread_Control          *idle
168);
169
170Thread_Control *_Scheduler_EDF_SMP_Remove_processor(
171  const Scheduler_Control *scheduler,
172  struct Per_CPU_Control  *cpu
173);
174
175void _Scheduler_EDF_SMP_Yield(
176  const Scheduler_Control *scheduler,
177  Thread_Control          *thread,
178  Scheduler_Node          *node
179);
180
181void _Scheduler_EDF_SMP_Start_idle(
182  const Scheduler_Control *scheduler,
183  Thread_Control          *idle,
184  struct Per_CPU_Control  *cpu
185);
186
187bool _Scheduler_EDF_SMP_Set_affinity(
188  const Scheduler_Control *scheduler,
189  Thread_Control          *thread,
190  Scheduler_Node          *node,
191  const Processor_mask    *affinity
192);
193
194/** @} */
195
196#ifdef __cplusplus
197}
198#endif
199
200#endif /* _RTEMS_SCORE_SCHEDULEREDFSMP_H */
Note: See TracBrowser for help on using the repository browser.