RTEMS  5.0.0
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 *) _Thread_Scheduler_get_home_node( the_thread );
49 }
50 
51 RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_downcast(
52  Scheduler_Node *node
53 )
54 {
55  return (Scheduler_priority_Node *) node;
56 }
57 
64  Chain_Control *ready_queues,
65  Priority_Control maximum_priority
66 )
67 {
68  size_t index;
69 
70  for ( index = 0 ; index <= (size_t) maximum_priority ; ++index ) {
71  _Chain_Initialize_empty( &ready_queues[ index ] );
72  }
73 }
74 
85  Chain_Node *node,
86  Scheduler_priority_Ready_queue *ready_queue,
88 )
89 {
90  Chain_Control *ready_chain = ready_queue->ready_chain;
91 
92  _Chain_Append_unprotected( ready_chain, node );
93  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
94 }
95 
106  Chain_Node *node,
107  Scheduler_priority_Ready_queue *ready_queue,
108  Priority_bit_map_Control *bit_map
109 )
110 {
111  Chain_Control *ready_chain = ready_queue->ready_chain;
112 
113  _Chain_Prepend_unprotected( ready_chain, node );
114  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
115 }
116 
125  Chain_Node *node,
126  Scheduler_priority_Ready_queue *ready_queue,
127  Priority_bit_map_Control *bit_map
128 )
129 {
130  Chain_Control *ready_chain = ready_queue->ready_chain;
131 
132  if ( _Chain_Has_only_one_node( ready_chain ) ) {
133  _Chain_Initialize_empty( ready_chain );
134  _Chain_Initialize_node( node );
135  _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
136  } else {
138  }
139 }
140 
141 RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
142  const Scheduler_Control *scheduler,
143  Thread_Control *the_thread,
144  Scheduler_Node *node
145 )
146 {
148  Scheduler_priority_Node *the_node;
149 
150  context = _Scheduler_priority_Get_context( scheduler );
151  the_node = _Scheduler_priority_Node_downcast( node );
152 
154  &the_thread->Object.Node,
155  &the_node->Ready_queue,
156  &context->Bit_map
157  );
158 }
159 
171  Priority_bit_map_Control *bit_map,
172  Chain_Control *ready_queues
173 )
174 {
175  Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
176  Chain_Node *first = _Chain_First( &ready_queues[ index ] );
177 
178  _Assert( first != _Chain_Tail( &ready_queues[ index ] ) );
179 
180  return first;
181 }
182 
190  const Scheduler_Control *scheduler,
191  Thread_Control *the_thread,
192  bool force_dispatch
193 )
194 {
196  _Scheduler_priority_Get_context( scheduler );
197  Thread_Control *heir = (Thread_Control *)
199  &context->Bit_map,
200  &context->Ready[ 0 ]
201  );
202 
203  ( void ) the_thread;
204 
205  _Scheduler_Update_heir( heir, force_dispatch );
206 }
207 
218  Scheduler_priority_Ready_queue *ready_queue,
219  unsigned int new_priority,
220  Priority_bit_map_Control *bit_map,
221  Chain_Control *ready_queues
222 )
223 {
224  ready_queue->current_priority = new_priority;
225  ready_queue->ready_chain = &ready_queues[ new_priority ];
226 
227  _Priority_bit_map_Initialize_information(
228  bit_map,
229  &ready_queue->Priority_map,
230  new_priority
231  );
232 }
233 
236 #ifdef __cplusplus
237 }
238 #endif
239 
240 #endif
241 /* end of include file */
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(Chain_Control *ready_queues, Priority_Control maximum_priority)
Ready queue initialization.
Definition: schedulerpriorityimpl.h:63
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:189
RTEMS_INLINE_ROUTINE void _Chain_Append_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Append a node (unprotected).
Definition: chainimpl.h:679
Definition: chain.h:65
Chain_Control Ready[0]
One ready queue per priority level.
Definition: schedulerpriority.h:74
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:105
Chain_Control * ready_chain
Definition: schedulerpriority.h:87
Definition: schedulerpriority.h:60
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
Definition: prioritybitmap.h:37
Priority_bit_map_Information Priority_map
Definition: schedulerpriority.h:90
Inlined Routines Associated with the Manipulation of the Scheduler.
Definition: chain.h:83
unsigned int current_priority
The thread priority currently used by the scheduler.
Definition: schedulerpriority.h:84
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:557
RTEMS_INLINE_ROUTINE void _Chain_Initialize_empty(Chain_Control *the_chain)
Initialize this chain as empty.
Definition: chainimpl.h:504
uint64_t Priority_Control
The thread priority control.
Definition: priority.h:66
Inlined Routines in the Priority Handler Bit Map Implementation.
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_First(const Chain_Control *the_chain)
Return pointer to chain&#39;s first node.
Definition: chainimpl.h:257
Definition: thread.h:728
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:124
RTEMS_INLINE_ROUTINE bool _Chain_Has_only_one_node(const Chain_Control *the_chain)
Does this chain have only one node.
Definition: chainimpl.h:449
Priority_bit_map_Control Bit_map
Bit map to indicate non-empty ready queues.
Definition: schedulerpriority.h:69
Data for ready queue operations.
Definition: schedulerpriority.h:80
Scheduler_priority_Ready_queue Ready_queue
The associated ready queue of this node.
Definition: schedulerpriority.h:105
Chain_Node Node
Definition: objectdata.h:41
Objects_Control Object
Definition: thread.h:730
RTEMS_INLINE_ROUTINE void _Priority_bit_map_Add(Priority_bit_map_Control *bit_map, Priority_bit_map_Information *bit_map_info)
Definition: prioritybitmapimpl.h:144
Scheduler node specialization for Deterministic Priority schedulers.
Definition: schedulerpriority.h:96
RTEMS_INLINE_ROUTINE Chain_Node * _Chain_Tail(Chain_Control *the_chain)
Return pointer to chain tail.
Definition: chainimpl.h:224
Chain Handler API.
RTEMS_INLINE_ROUTINE void _Chain_Initialize_node(Chain_Node *the_node)
Initializes a chain node.
Definition: chainimpl.h:119
unsigned context
Definition: tlb.h:108
Scheduler control.
Definition: scheduler.h:266
Scheduler node for per-thread data.
Definition: schedulernode.h:65
RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(Scheduler_priority_Ready_queue *ready_queue, unsigned int 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:217
Constants and Structures Related with the Thread Control Block.
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:84
RTEMS_INLINE_ROUTINE void _Chain_Prepend_unprotected(Chain_Control *the_chain, Chain_Node *the_node)
Prepend a node (unprotected).
Definition: chainimpl.h:728
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:170