1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup ScoreSchedulerPrioritySMP |
---|
5 | * |
---|
6 | * @brief Deterministic Priority SMP Scheduler API |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H |
---|
24 | #define _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H |
---|
25 | |
---|
26 | #include <rtems/score/schedulerprioritysmp.h> |
---|
27 | #include <rtems/score/schedulerpriorityimpl.h> |
---|
28 | #include <rtems/score/schedulersimpleimpl.h> |
---|
29 | |
---|
30 | #ifdef __cplusplus |
---|
31 | extern "C" { |
---|
32 | #endif /* __cplusplus */ |
---|
33 | |
---|
34 | /** |
---|
35 | * @ingroup ScoreSchedulerPrioritySMP |
---|
36 | * @{ |
---|
37 | */ |
---|
38 | |
---|
39 | static inline Scheduler_priority_SMP_Context *_Scheduler_priority_SMP_Get_self( |
---|
40 | Scheduler_Context *context |
---|
41 | ) |
---|
42 | { |
---|
43 | return (Scheduler_priority_SMP_Context *) context; |
---|
44 | } |
---|
45 | |
---|
46 | static inline Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Node_get( |
---|
47 | Thread_Control *thread |
---|
48 | ) |
---|
49 | { |
---|
50 | return (Scheduler_priority_SMP_Node *) _Scheduler_Node_get( thread ); |
---|
51 | } |
---|
52 | |
---|
53 | static Scheduler_priority_SMP_Node *_Scheduler_priority_SMP_Node_downcast( |
---|
54 | Scheduler_Node *node |
---|
55 | ) |
---|
56 | { |
---|
57 | return (Scheduler_priority_SMP_Node *) node; |
---|
58 | } |
---|
59 | |
---|
60 | static inline void _Scheduler_priority_SMP_Move_from_scheduled_to_ready( |
---|
61 | Scheduler_Context *context, |
---|
62 | Thread_Control *scheduled_to_ready |
---|
63 | ) |
---|
64 | { |
---|
65 | Scheduler_priority_SMP_Context *self = |
---|
66 | _Scheduler_priority_SMP_Get_self( context ); |
---|
67 | Scheduler_priority_SMP_Node *node = |
---|
68 | _Scheduler_priority_SMP_Node_get( scheduled_to_ready ); |
---|
69 | |
---|
70 | _Chain_Extract_unprotected( &scheduled_to_ready->Object.Node ); |
---|
71 | _Scheduler_priority_Ready_queue_enqueue_first( |
---|
72 | &scheduled_to_ready->Object.Node, |
---|
73 | &node->Ready_queue, |
---|
74 | &self->Bit_map |
---|
75 | ); |
---|
76 | } |
---|
77 | |
---|
78 | static inline void _Scheduler_priority_SMP_Move_from_ready_to_scheduled( |
---|
79 | Scheduler_Context *context, |
---|
80 | Thread_Control *ready_to_scheduled |
---|
81 | ) |
---|
82 | { |
---|
83 | Scheduler_priority_SMP_Context *self = |
---|
84 | _Scheduler_priority_SMP_Get_self( context ); |
---|
85 | Scheduler_priority_SMP_Node *node = |
---|
86 | _Scheduler_priority_SMP_Node_get( ready_to_scheduled ); |
---|
87 | |
---|
88 | _Scheduler_priority_Ready_queue_extract( |
---|
89 | &ready_to_scheduled->Object.Node, |
---|
90 | &node->Ready_queue, |
---|
91 | &self->Bit_map |
---|
92 | ); |
---|
93 | _Scheduler_simple_Insert_priority_fifo( |
---|
94 | &self->Base.Scheduled, |
---|
95 | &ready_to_scheduled->Object.Node |
---|
96 | ); |
---|
97 | } |
---|
98 | |
---|
99 | static inline void _Scheduler_priority_SMP_Insert_ready_lifo( |
---|
100 | Scheduler_Context *context, |
---|
101 | Thread_Control *thread |
---|
102 | ) |
---|
103 | { |
---|
104 | Scheduler_priority_SMP_Context *self = |
---|
105 | _Scheduler_priority_SMP_Get_self( context ); |
---|
106 | Scheduler_priority_SMP_Node *node = |
---|
107 | _Scheduler_priority_SMP_Node_get( thread ); |
---|
108 | |
---|
109 | _Scheduler_priority_Ready_queue_enqueue( |
---|
110 | &thread->Object.Node, |
---|
111 | &node->Ready_queue, |
---|
112 | &self->Bit_map |
---|
113 | ); |
---|
114 | } |
---|
115 | |
---|
116 | static inline void _Scheduler_priority_SMP_Insert_ready_fifo( |
---|
117 | Scheduler_Context *context, |
---|
118 | Thread_Control *thread |
---|
119 | ) |
---|
120 | { |
---|
121 | Scheduler_priority_SMP_Context *self = |
---|
122 | _Scheduler_priority_SMP_Get_self( context ); |
---|
123 | Scheduler_priority_SMP_Node *node = |
---|
124 | _Scheduler_priority_SMP_Node_get( thread ); |
---|
125 | |
---|
126 | _Scheduler_priority_Ready_queue_enqueue_first( |
---|
127 | &thread->Object.Node, |
---|
128 | &node->Ready_queue, |
---|
129 | &self->Bit_map |
---|
130 | ); |
---|
131 | } |
---|
132 | |
---|
133 | static inline void _Scheduler_priority_SMP_Extract_from_ready( |
---|
134 | Scheduler_Context *context, |
---|
135 | Thread_Control *thread |
---|
136 | ) |
---|
137 | { |
---|
138 | Scheduler_priority_SMP_Context *self = |
---|
139 | _Scheduler_priority_SMP_Get_self( context ); |
---|
140 | Scheduler_priority_SMP_Node *node = |
---|
141 | _Scheduler_priority_SMP_Node_get( thread ); |
---|
142 | |
---|
143 | _Scheduler_priority_Ready_queue_extract( |
---|
144 | &thread->Object.Node, |
---|
145 | &node->Ready_queue, |
---|
146 | &self->Bit_map |
---|
147 | ); |
---|
148 | } |
---|
149 | |
---|
150 | static inline void _Scheduler_priority_SMP_Do_update( |
---|
151 | Scheduler_Context *context, |
---|
152 | Scheduler_Node *base_node, |
---|
153 | Priority_Control new_priority |
---|
154 | ) |
---|
155 | { |
---|
156 | Scheduler_priority_SMP_Context *self = |
---|
157 | _Scheduler_priority_SMP_Get_self( context ); |
---|
158 | Scheduler_priority_SMP_Node *node = |
---|
159 | _Scheduler_priority_SMP_Node_downcast( base_node ); |
---|
160 | |
---|
161 | _Scheduler_priority_Ready_queue_update( |
---|
162 | &node->Ready_queue, |
---|
163 | new_priority, |
---|
164 | &self->Bit_map, |
---|
165 | &self->Ready[ 0 ] |
---|
166 | ); |
---|
167 | } |
---|
168 | |
---|
169 | /** @} */ |
---|
170 | |
---|
171 | #ifdef __cplusplus |
---|
172 | } |
---|
173 | #endif /* __cplusplus */ |
---|
174 | |
---|
175 | #endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMPIMPL_H */ |
---|