2 * @file rtems/score/schedulerpriority.h
4 * This include file contains all the constants and structures associated
5 * with the manipulation of threads for the priority-based scheduler.
9 * Copryight (c) 2010 Gedare Bloom.
10 * Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.com/license/LICENSE.
16 * $Id: schedulerpriority.h,v 1.8 2011/03/08 19:27:35 joel Exp $
19 #ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H
20 #define _RTEMS_SCORE_SCHEDULERPRIORITY_H
22 #include <rtems/score/chain.h>
23 #include <rtems/score/priority.h>
24 #include <rtems/score/scheduler.h>
31 * @addtogroup ScoreScheduler
37 * Entry points for the Deterministic Priority Based Scheduler.
39 #define SCHEDULER_PRIORITY_ENTRY_POINTS \
41 _Scheduler_priority_Initialize, /* initialize entry point */ \
42 _Scheduler_priority_Schedule, /* schedule entry point */ \
43 _Scheduler_priority_Yield, /* yield entry point */ \
44 _Scheduler_priority_Block, /* block entry point */ \
45 _Scheduler_priority_Unblock, /* unblock entry point */ \
46 _Scheduler_priority_Allocate, /* allocate entry point */ \
47 _Scheduler_priority_Free, /* free entry point */ \
48 _Scheduler_priority_Update, /* update entry point */ \
49 _Scheduler_priority_Enqueue, /* enqueue entry point */ \
50 _Scheduler_priority_Enqueue_first, /* enqueue_first entry point */ \
51 _Scheduler_priority_Extract /* extract entry point */ \
55 * Per-thread data related to the _Scheduler_PRIORITY scheduling policy.
58 /** This field points to the Ready FIFO for this thread's priority. */
59 Chain_Control *ready_chain;
61 /** This field contains precalculated priority map indices. */
62 Priority_bit_map_Information Priority_map;
63 } Scheduler_priority_Per_thread;
66 * This routine initializes the priority scheduler.
68 void _Scheduler_priority_Initialize(void);
71 * This routine removes @a the_thread from the scheduling decision,
72 * that is, removes it from the ready queue. It performs
73 * any necessary scheduling operations including the selection of
76 * @param[in] the_thread is the thread to be blocked
78 void _Scheduler_priority_Block(
79 Thread_Control *the_thread
83 * This kernel routine sets the heir thread to be the next ready thread
84 * by invoking the_scheduler->ready_queue->operations->first().
86 void _Scheduler_priority_Schedule(void);
89 * This routine allocates @a the_thread->scheduler.
91 * @param[in] the_thread is the thread the scheduler is allocating
92 * management memory for
94 void * _Scheduler_priority_Allocate(
95 Thread_Control *the_thread
99 * This routine frees @a the_thread->scheduler.
101 * @param[in] the_thread is the thread whose scheduler specific information
102 * will be deallocated.
104 void _Scheduler_priority_Free(
105 Thread_Control *the_thread
109 * This routine updates @a the_thread->scheduler based on @a the_scheduler
110 * structures and thread state.
112 * @param[in] the_thread will have its scheduler specific information
115 void _Scheduler_priority_Update(
116 Thread_Control *the_thread
120 * This routine adds @a the_thread to the scheduling decision,
121 * that is, adds it to the ready queue and
122 * updates any appropriate scheduling variables, for example the heir thread.
124 * @param[in] the_thread will be unblocked
126 void _Scheduler_priority_Unblock(
127 Thread_Control *the_thread
131 * This routine is invoked when a thread wishes to voluntarily
132 * transfer control of the processor to another thread in the queue.
134 * This routine will remove the running THREAD from the ready queue
135 * and place it immediately at the rear of this chain. Reset timeslice
136 * and yield the processor functions both use this routine, therefore if
137 * reset is true and this is the only thread on the queue then the
138 * timeslice counter is reset. The heir THREAD will be updated if the
139 * running is also the currently the heir.
141 void _Scheduler_priority_Yield( void );
144 * This routine puts @a the_thread on to the priority-based ready queue.
146 * @param[in] the_thread will be enqueued at the TAIL of its priority.
148 void _Scheduler_priority_Enqueue(
149 Thread_Control *the_thread
153 * This routine puts @a the_thread to the head of the ready queue.
154 * For priority-based ready queues, the thread will be the first thread
155 * at its priority level.
157 * @param[in] the_thread will be enqueued at the HEAD of its priority.
159 void _Scheduler_priority_Enqueue_first(
160 Thread_Control *the_thread
164 * This routine removes a specific thread from the scheduler's set
167 * @param[in] the_thread will be extracted from the ready set.
169 void _Scheduler_priority_Extract(
170 Thread_Control *the_thread
174 * This is the major bit map.
176 extern volatile Priority_bit_map_Control _Priority_Major_bit_map;
179 * This is the minor bit map.
181 extern Priority_bit_map_Control _Priority_Bit_map[16] CPU_STRUCTURE_ALIGNMENT;
183 #ifndef __RTEMS_APPLICATION__
184 #include <rtems/score/schedulerpriority.inl>
194 /* end of include file */