RTEMS CPU Kit with SuperCore  4.11.2
schedulerpriorityimpl.h
Go to the documentation of this file.
1 
11 /*
12  * Copyright (C) 2010 Gedare Bloom.
13  * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
14  *
15  * The license and distribution terms for this file may be
16  * found in the file LICENSE in this distribution or at
17  * http://www.rtems.org/license/LICENSE.
18  */
19 
20 #ifndef _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
21 #define _RTEMS_SCORE_SCHEDULERPRIORITYIMPL_H
22 
24 #include <rtems/score/chainimpl.h>
27 #include <rtems/score/thread.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
39  _Scheduler_priority_Get_context( const Scheduler_Control *scheduler )
40 {
41  return (Scheduler_priority_Context *) _Scheduler_Get_context( scheduler );
42 }
43 
44 RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Thread_get_node(
45  Thread_Control *the_thread
46 )
47 {
48  return (Scheduler_priority_Node *) _Scheduler_Thread_get_node( the_thread );
49 }
50 
57  Chain_Control *ready_queues
58 )
59 {
60  size_t index;
61 
62  /* initialize ready queue structures */
63  for( index=0; index <= PRIORITY_MAXIMUM; index++)
64  _Chain_Initialize_empty( &ready_queues[index] );
65 }
66 
77  Chain_Node *node,
78  Scheduler_priority_Ready_queue *ready_queue,
80 )
81 {
82  Chain_Control *ready_chain = ready_queue->ready_chain;
83 
84  _Chain_Append_unprotected( ready_chain, node );
85  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
86 }
87 
98  Chain_Node *node,
99  Scheduler_priority_Ready_queue *ready_queue,
100  Priority_bit_map_Control *bit_map
101 )
102 {
103  Chain_Control *ready_chain = ready_queue->ready_chain;
104 
105  _Chain_Prepend_unprotected( ready_chain, node );
106  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
107 }
108 
117  Chain_Node *node,
118  Scheduler_priority_Ready_queue *ready_queue,
119  Priority_bit_map_Control *bit_map
120 )
121 {
122  Chain_Control *ready_chain = ready_queue->ready_chain;
123 
124  if ( _Chain_Has_only_one_node( ready_chain ) ) {
125  _Chain_Initialize_empty( ready_chain );
126  _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
127  } else {
129  }
130 }
131 
132 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
133  const Scheduler_Control *scheduler,
134  Thread_Control *the_thread
135 )
136 {
137  Scheduler_priority_Context *context =
138  _Scheduler_priority_Get_context( scheduler );
139  Scheduler_priority_Node *node = _Scheduler_priority_Thread_get_node( the_thread );
140 
142  &the_thread->Object.Node,
143  &node->Ready_queue,
144  &context->Bit_map
145  );
146 }
147 
159  Priority_bit_map_Control *bit_map,
160  Chain_Control *ready_queues
161 )
162 {
163  Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
164  Chain_Node *first = _Chain_First( &ready_queues[ index ] );
165 
166  _Assert( first != _Chain_Tail( &ready_queues[ index ] ) );
167 
168  return first;
169 }
170 
178  const Scheduler_Control *scheduler,
179  Thread_Control *the_thread,
180  bool force_dispatch
181 )
182 {
183  Scheduler_priority_Context *context =
184  _Scheduler_priority_Get_context( scheduler );
185  Thread_Control *heir = (Thread_Control *)
187  &context->Bit_map,
188  &context->Ready[ 0 ]
189  );
190 
191  ( void ) the_thread;
192 
193  _Scheduler_Update_heir( heir, force_dispatch );
194 }
195 
206  Scheduler_priority_Ready_queue *ready_queue,
207  Priority_Control new_priority,
208  Priority_bit_map_Control *bit_map,
209  Chain_Control *ready_queues
210 )
211 {
212  ready_queue->ready_chain = &ready_queues[ new_priority ];
213 
214  _Priority_bit_map_Initialize_information(
215  bit_map,
216  &ready_queue->Priority_map,
217  new_priority
218  );
219 }
220 
230  Priority_Control p1,
232 )
233 {
234  /* High priority in priority scheduler is represented by low numbers. */
235  return ( p2 - p1 );
236 }
237 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif
245 /* end of include file */
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(const Scheduler_Control *scheduler, Thread_Control *the_thread, bool force_dispatch)
Scheduling decision logic.
Definition: schedulerpriorityimpl.h:177
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Append a node (unprotected).
Definition: chainimpl.h:743
This is used to manage each element (node) which is placed on a chain.
Definition: chain.h:65
Chain_Control Ready[0]
One ready queue per priority level.
Definition: schedulerpriority.h:73
Scheduler control.
Definition: scheduler.h:192
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue as first.
Definition: schedulerpriorityimpl.h:97
Chain_Control * ready_chain
This field points to the Ready FIFO for this thread&#39;s priority.
Definition: schedulerpriority.h:81
Definition: schedulerpriority.h:59
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
Definition: prioritybitmap.h:40
Priority_bit_map_Information Priority_map
This field contains precalculated priority map indices.
Definition: schedulerpriority.h:84
Inlined Routines Associated with the Manipulation of the Scheduler.
This is used to manage a chain.
Definition: chain.h:83
#define PRIORITY_MAXIMUM
This defines the lowest (least important) thread priority.
Definition: priority.h:76
Thread Manipulation with the Priority-Based Scheduler.
RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(Chain_Node *the_node)
Extract this node (unprotected).
Definition: chainimpl.h:639
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initialize this chain as empty.
Definition: chainimpl.h:613
Constants and Structures Related with the Thread Control Block.
Inlined Routines in the Priority Handler Bit Map Implementation.
RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body(Priority_Control p1, Priority_Control p2)
Priority comparison.
Definition: schedulerpriorityimpl.h:229
uint32_t Priority_Control
The following type defines the control block used to manage thread priorities.
Definition: priority.h:56
Objects_Control Object
This field is the object management structure for each thread.
Definition: thread.h:673
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Extracts a node from the specified ready queue.
Definition: schedulerpriorityimpl.h:116
RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Does this chain have only one node.
Definition: chainimpl.h:558
This structure defines the Thread Control Block (TCB).
Definition: thread.h:671
Priority_bit_map_Control Bit_map
Bit map to indicate non-empty ready queues.
Definition: schedulerpriority.h:68
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(Scheduler_priority_Ready_queue *ready_queue, Priority_Control new_priority, Priority_bit_map_Control *bit_map, Chain_Control *ready_queues)
Updates the specified ready queue data according to the new priority value.
Definition: schedulerpriorityimpl.h:205
Data for ready queue operations.
Definition: schedulerpriority.h:79
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(Chain_Control *ready_queues)
Ready queue initialization.
Definition: schedulerpriorityimpl.h:56
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Definition: schedulerpriority.h:99
Chain_Node Node
This is the chain node portion of an object.
Definition: object.h:234
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Priority Queue implemented by bit map.
Definition: prioritybitmapimpl.h:184
#define _Assert(_e)
Assertion similar to assert() controlled via RTEMS_DEBUG instead of NDEBUG.
Definition: assert.h:83
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:90
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Return pointer to chain tail.
Definition: chainimpl.h:333
Chain Handler API.
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(Chain_Control *the_chain)
Return pointer to chain&#39;s first node.
Definition: chainimpl.h:366
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(Chain_Node *node, Scheduler_priority_Ready_queue *ready_queue, Priority_bit_map_Control *bit_map)
Enqueues a node on the specified ready queue.
Definition: schedulerpriorityimpl.h:76
RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepend a node (unprotected).
Definition: chainimpl.h:787
RTEMS_INLINE_ROUTINE Chain_Node * _Scheduler_priority_Ready_queue_first(Priority_bit_map_Control *bit_map, Chain_Control *ready_queues)
Return a pointer to the first node.
Definition: schedulerpriorityimpl.h:158