source: rtems/cpukit/score/include/rtems/score/schedulerpriorityimpl.h @ 0f41cc3

4.115
Last change on this file since 0f41cc3 was 0f41cc3, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/14 at 09:25:07

score: _Scheduler_priority_Ready_queue_requeue()

Delete unused function _Scheduler_priority_Ready_queue_requeue().

  • Property mode set to 100644
File size: 6.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the Manipulation of the
5 * Priority-Based Scheduling Structures
6 *
7 * This inline file contains all of the inlined routines associated with
8 * the manipulation of the priority-based scheduling structures.
9 */
10
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
23#include <rtems/score/schedulerpriority.h>
24#include <rtems/score/chainimpl.h>
25#include <rtems/score/prioritybitmapimpl.h>
26#include <rtems/score/schedulerimpl.h>
27#include <rtems/score/thread.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 * @addtogroup ScoreSchedulerDPS
35 */
36/**@{**/
37
38RTEMS_INLINE_ROUTINE Scheduler_priority_Context *
39  _Scheduler_priority_Get_context( const Scheduler_Control *scheduler )
40{
41  return (Scheduler_priority_Context *) scheduler->context;
42}
43
44RTEMS_INLINE_ROUTINE Scheduler_priority_Node *_Scheduler_priority_Node_get(
45  Thread_Control *the_thread
46)
47{
48  return (Scheduler_priority_Node *) _Scheduler_Node_get( the_thread );
49}
50
51/**
52 * @brief Ready queue initialization.
53 *
54 * This routine initializes @a ready_queues for priority-based scheduling.
55 */
56RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(
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
67RTEMS_INLINE_ROUTINE Scheduler_priority_Node *
68_Scheduler_priority_Get_scheduler_info( Thread_Control *thread )
69{
70  return ( Scheduler_priority_Node * ) thread->scheduler_node;
71}
72
73/**
74 * @brief Enqueues a thread on the specified ready queue.
75 *
76 * The thread is placed as the last element of its priority group.
77 *
78 * @param[in] the_thread The thread to enqueue.
79 * @param[in] ready_queue The ready queue.
80 * @param[in] bit_map The priority bit map of the scheduler instance.
81 */
82RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
83  Thread_Control                 *the_thread,
84  Scheduler_priority_Ready_queue *ready_queue,
85  Priority_bit_map_Control       *bit_map
86)
87{
88  Chain_Control *ready_chain = ready_queue->ready_chain;
89
90  _Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
91  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
92}
93
94/**
95 * @brief Enqueues a thread on the specified ready queue as first.
96 *
97 * The thread is placed as the first element of its priority group.
98 *
99 * @param[in] the_thread The thread to enqueue as first.
100 * @param[in] ready_queue The ready queue.
101 * @param[in] bit_map The priority bit map of the scheduler instance.
102 */
103RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
104  Thread_Control                 *the_thread,
105  Scheduler_priority_Ready_queue *ready_queue,
106  Priority_bit_map_Control       *bit_map
107)
108{
109  Chain_Control *ready_chain = ready_queue->ready_chain;
110
111  _Chain_Prepend_unprotected( ready_chain, &the_thread->Object.Node );
112  _Priority_bit_map_Add( bit_map, &ready_queue->Priority_map );
113}
114
115/**
116 * @brief Extracts a thread from the specified ready queue.
117 *
118 * @param[in] the_thread The thread to extract.
119 * @param[in] ready_queue The ready queue.
120 * @param[in] bit_map The priority bit map of the scheduler instance.
121 */
122RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
123  Thread_Control                 *the_thread,
124  Scheduler_priority_Ready_queue *ready_queue,
125  Priority_bit_map_Control       *bit_map
126)
127{
128  Chain_Control *ready_chain = ready_queue->ready_chain;
129
130  if ( _Chain_Has_only_one_node( ready_chain ) ) {
131    _Chain_Initialize_empty( ready_chain );
132    _Priority_bit_map_Remove( bit_map, &ready_queue->Priority_map );
133  } else {
134    _Chain_Extract_unprotected( &the_thread->Object.Node );
135  }
136}
137
138RTEMS_INLINE_ROUTINE void _Scheduler_priority_Extract_body(
139  const Scheduler_Control *scheduler,
140  Thread_Control          *the_thread
141)
142{
143  Scheduler_priority_Context *context =
144    _Scheduler_priority_Get_context( scheduler );
145  Scheduler_priority_Node *node = _Scheduler_priority_Node_get( the_thread );
146
147  _Scheduler_priority_Ready_queue_extract(
148    the_thread,
149    &node->Ready_queue,
150    &context->Bit_map
151  );
152}
153
154/**
155 * @brief Return a pointer to the first thread.
156 *
157 * This routines returns a pointer to the first thread on @a ready_queues.
158 *
159 * @param[in] bit_map The priority bit map of the scheduler instance.
160 * @param[in] ready_queues The ready queues of the scheduler instance.
161 *
162 * @return This method returns the first thread or NULL
163 */
164RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_priority_Ready_queue_first(
165  Priority_bit_map_Control *bit_map,
166  Chain_Control            *ready_queues
167)
168{
169  Priority_Control index = _Priority_bit_map_Get_highest( bit_map );
170
171  return (Thread_Control *) _Chain_First( &ready_queues[ index ] );
172}
173
174/**
175 * @brief Scheduling decision logic.
176 *
177 * This kernel routine implements scheduling decision logic
178 * for priority-based scheduling.
179 */
180RTEMS_INLINE_ROUTINE void _Scheduler_priority_Schedule_body(
181  const Scheduler_Control *scheduler,
182  Thread_Control          *the_thread,
183  bool                     force_dispatch
184)
185{
186  Scheduler_priority_Context *context =
187    _Scheduler_priority_Get_context( scheduler );
188  Thread_Control *heir = _Scheduler_priority_Ready_queue_first(
189    &context->Bit_map,
190    &context->Ready[ 0 ]
191  );
192
193  ( void ) the_thread;
194
195  _Scheduler_Update_heir( heir, force_dispatch );
196}
197
198/**
199 * @brief Updates the specified ready queue data according to the current
200 * priority of the thread.
201 *
202 * @param[in] the_thread The thread.
203 * @param[in] ready_queue The ready queue.
204 * @param[in] bit_map The priority bit map of the scheduler instance.
205 * @param[in] ready_queues The ready queues of the scheduler instance.
206 */
207RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_update(
208  Thread_Control                 *the_thread,
209  Scheduler_priority_Ready_queue *ready_queue,
210  Priority_bit_map_Control       *bit_map,
211  Chain_Control                  *ready_queues
212)
213{
214  Priority_Control priority = the_thread->current_priority;
215  ready_queue->ready_chain = &ready_queues[ priority ];
216
217  _Priority_bit_map_Initialize_information(
218    bit_map,
219    &ready_queue->Priority_map,
220    priority
221  );
222}
223
224/**
225 * @brief Priority comparison.
226 *
227 * This routine implements priority comparison for priority-based
228 * scheduling.
229 *
230 * @return >0 for higher priority, 0 for equal and <0 for lower priority.
231 */
232RTEMS_INLINE_ROUTINE int _Scheduler_priority_Priority_compare_body(
233  Priority_Control      p1,
234  Priority_Control      p2
235)
236{
237  /* High priority in priority scheduler is represented by low numbers. */
238  return ( p2 - p1 );
239}
240
241/** @} */
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif
248/* end of include file */
Note: See TracBrowser for help on using the repository browser.