File indexing completed on 2025-05-11 08:24:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
0039 #define _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
0040
0041 #include <rtems/score/schedulerpriority.h>
0042 #include <rtems/score/chainimpl.h>
0043 #include <rtems/score/prioritybitmapimpl.h>
0044 #include <rtems/score/scheduleruniimpl.h>
0045 #include <rtems/score/thread.h>
0046
0047 #ifdef __cplusplus
0048 extern "C" {
0049 #endif
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 static inline Scheduler_priority_Context *
0065 _Scheduler_priority_Get_context( const Scheduler_Control *scheduler )
0066 {
0067 return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler );
0068 }
0069
0070
0071
0072
0073
0074
0075
0076
0077 static inline Scheduler_priority_Node *_Scheduler_priority_Thread_get_node(
0078 Thread_Control *the_thread
0079 )
0080 {
0081 return (Scheduler_priority_Node *) _Thread_Scheduler_get_home_node( the_thread );
0082 }
0083
0084
0085
0086
0087
0088
0089
0090
0091 static inline Scheduler_priority_Node *_Scheduler_priority_Node_downcast(
0092 Scheduler_Node *node
0093 )
0094 {
0095 return (Scheduler_priority_Node *) node;
0096 }
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 static inline void _Scheduler_priority_Ready_queue_initialize(
0107 Chain_Control *ready_queues,
0108 Priority_Control maximum_priority
0109 )
0110 {
0111 size_t index;
0112
0113 for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) {
0114 _Chain_Initialize_empty( &ready_queues[ index ] );
0115 }
0116 }
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 static inline void _Scheduler_priority_Ready_queue_enqueue(
0128 Chain_Node *node,
0129 Scheduler_priority_Ready_queue *ready_queue,
0130 Priority_bit_map_Control *bit_map
0131 )
0132 {
0133 Chain_Control *ready_chain = ready_queue->ready_chain;
0134
0135 _Chain_Append_unprotected( ready_chain, node );
0136 _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
0137 }
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 static inline void _Scheduler_priority_Ready_queue_enqueue_first(
0149 Chain_Node *node,
0150 Scheduler_priority_Ready_queue *ready_queue,
0151 Priority_bit_map_Control *bit_map
0152 )
0153 {
0154 Chain_Control *ready_chain = ready_queue->ready_chain;
0155
0156 _Chain_Prepend_unprotected( ready_chain, node );
0157 _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
0158 }
0159
0160
0161
0162
0163
0164
0165
0166
0167 static inline void _Scheduler_priority_Ready_queue_extract(
0168 Chain_Node *node,
0169 Scheduler_priority_Ready_queue *ready_queue,
0170 Priority_bit_map_Control *bit_map
0171 )
0172 {
0173 Chain_Control *ready_chain = ready_queue->ready_chain;
0174
0175 if ( _Chain_Has_only_one_node( ready_chain ) ) {
0176 _Chain_Initialize_empty( ready_chain );
0177 _Chain_Initialize_node( node );
0178 _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
0179 } else {
0180 _Chain_Extract_unprotected( node );
0181 }
0182 }
0183
0184
0185
0186
0187
0188
0189
0190
0191 static inline void _Scheduler_priority_Extract_body(
0192 const Scheduler_Control *scheduler,
0193 Thread_Control *the_thread,
0194 Scheduler_Node *node
0195 )
0196 {
0197 Scheduler_priority_Context *context;
0198 Scheduler_priority_Node *the_node;
0199
0200 context = _Scheduler_priority_Get_context( scheduler );
0201 the_node = _Scheduler_priority_Node_downcast( node );
0202
0203 _Scheduler_priority_Ready_queue_extract(
0204 &the_thread->Object.Node,
0205 &the_node->Ready_queue,
0206 &context->Bit_map
0207 );
0208 }
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220 static inline Chain_Node *_Scheduler_priority_Ready_queue_first(
0221 Priority_bit_map_Control *bit_map,
0222 Chain_Control *ready_queues
0223 )
0224 {
0225 Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
0226 Chain_Node *first = _Chain_First( &ready_queues[ index ] );
0227
0228 _Assert( first != _Chain_Tail( &ready_queues[ index ] ) );
0229
0230 return first;
0231 }
0232
0233
0234
0235
0236
0237
0238 static inline Thread_Control *_Scheduler_priority_Get_highest_ready(
0239 const Scheduler_Control *scheduler
0240 )
0241 {
0242 Scheduler_priority_Context *context =
0243 _Scheduler_priority_Get_context( scheduler );
0244
0245 return (Thread_Control *) _Scheduler_priority_Ready_queue_first(
0246 &context->Bit_map,
0247 &context->Ready[ 0 ]
0248 );
0249 }
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260 static inline void _Scheduler_priority_Ready_queue_update(
0261 Scheduler_priority_Ready_queue *ready_queue,
0262 unsigned int new_priority,
0263 Priority_bit_map_Control *bit_map,
0264 Chain_Control *ready_queues
0265 )
0266 {
0267 ready_queue->current_priority = new_priority;
0268 ready_queue->ready_chain = &ready_queues[ new_priority ];
0269
0270 _Priority_bit_map_Initialize_information(
0271 bit_map,
0272 &ready_queue->Priority_map,
0273 new_priority
0274 );
0275 }
0276
0277
0278
0279 #ifdef __cplusplus
0280 }
0281 #endif
0282
0283 #endif
0284