source: rtems/cpukit/score/include/rtems/score/schedulerpriority.h @ a7e4de2

4.115
Last change on this file since a7e4de2 was a7e4de2, checked in by Joel Sherrill <joel.sherrill@…>, on 03/06/15 at 20:33:08

Fix even more Doxygen issues

  • Property mode set to 100644
File size: 6.1 KB
Line 
1/**
2 *  @file  rtems/score/schedulerpriority.h
3 *
4 *  @brief Thread Manipulation with the Priority-Based Scheduler
5 *
6 *  This include file contains all the constants and structures associated
7 *  with the manipulation of threads for the priority-based scheduler.
8 */
9
10/*
11 *  Copryight (c) 2010 Gedare Bloom.
12 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_SCHEDULERPRIORITY_H
20#define _RTEMS_SCORE_SCHEDULERPRIORITY_H
21
22#include <rtems/score/chain.h>
23#include <rtems/score/prioritybitmap.h>
24#include <rtems/score/scheduler.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @defgroup ScoreSchedulerDPS Deterministic Priority Scheduler
32 *
33 * @ingroup ScoreScheduler
34 */
35/**@{*/
36
37/**
38 *  Entry points for the Deterministic Priority Based Scheduler.
39 */
40#define SCHEDULER_PRIORITY_ENTRY_POINTS \
41  { \
42    _Scheduler_priority_Initialize,       /* initialize entry point */ \
43    _Scheduler_priority_Schedule,         /* schedule entry point */ \
44    _Scheduler_priority_Yield,            /* yield entry point */ \
45    _Scheduler_priority_Block,            /* block entry point */ \
46    _Scheduler_priority_Unblock,          /* unblock entry point */ \
47    _Scheduler_priority_Change_priority,  /* change priority entry point */ \
48    SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP \
49    _Scheduler_default_Node_initialize,   /* node initialize entry point */ \
50    _Scheduler_default_Node_destroy,      /* node destroy entry point */ \
51    _Scheduler_priority_Update_priority,  /* update priority entry point */ \
52    _Scheduler_priority_Priority_compare, /* compares two priorities */ \
53    _Scheduler_default_Release_job,       /* new period of task */ \
54    _Scheduler_default_Tick,              /* tick entry point */ \
55    _Scheduler_default_Start_idle         /* start idle entry point */ \
56    SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
57  }
58
59typedef struct {
60  /**
61   * @brief Basic scheduler context.
62   */
63  Scheduler_Context Base;
64
65  /**
66   * @brief Bit map to indicate non-empty ready queues.
67   */
68  Priority_bit_map_Control Bit_map;
69
70  /**
71   * @brief One ready queue per priority level.
72   */
73  Chain_Control Ready[ 0 ];
74} Scheduler_priority_Context;
75
76/**
77 * @brief Data for ready queue operations.
78 */
79typedef struct {
80  /** This field points to the Ready FIFO for this thread's priority. */
81  Chain_Control                        *ready_chain;
82
83  /** This field contains precalculated priority map indices. */
84  Priority_bit_map_Information          Priority_map;
85} Scheduler_priority_Ready_queue;
86
87/**
88 * @brief Scheduler node specialization for Deterministic Priority schedulers.
89 */
90typedef struct {
91  /**
92   * @brief Basic scheduler node.
93   */
94  Scheduler_Node Base;
95
96  /**
97   * @brief The associated ready queue of this node.
98   */
99  Scheduler_priority_Ready_queue Ready_queue;
100} Scheduler_priority_Node;
101
102/**
103 * @brief Initializes the priority scheduler.
104 * This routine initializes the priority scheduler.
105 */
106void _Scheduler_priority_Initialize( const Scheduler_Control *scheduler );
107
108/**
109 *  @brief Removes @a the_thread from the scheduling decision.
110 *
111 *  This routine removes @a the_thread from the scheduling decision,
112 *  that is, removes it from the ready queue.  It performs
113 *  any necessary scheduling operations including the selection of
114 *  a new heir thread.
115 *
116 *  @param[in] scheduler The scheduler instance.
117 *  @param[in] the_thread is the thread to be blocked
118 */
119void _Scheduler_priority_Block(
120  const Scheduler_Control *scheduler,
121  Thread_Control          *the_thread
122);
123
124/**
125 *  @brief Sets the heir thread to be the next ready thread.
126 *
127 *  This kernel routine sets the heir thread to be the next ready thread
128 *  by invoking the_scheduler->ready_queue->operations->first().
129 */
130void _Scheduler_priority_Schedule(
131  const Scheduler_Control *scheduler,
132  Thread_Control          *the_thread
133);
134
135/**
136 *  @brief Updates the scheduler node to reflect the new priority of the
137 *  thread.
138 */
139void _Scheduler_priority_Update_priority(
140  const Scheduler_Control *scheduler,
141  Thread_Control          *the_thread,
142  Priority_Control         new_priority
143);
144
145/**
146 *  @brief Add @a the_thread to the scheduling decision.
147 *
148 *  This routine adds @a the_thread to the scheduling decision,
149 *  that is, adds it to the ready queue and
150 *  updates any appropriate scheduling variables, for example the heir thread.
151 *
152 *  @param[in] scheduler The scheduler instance.
153 *  @param[in] the_thread will be unblocked
154 */
155Scheduler_Void_or_thread _Scheduler_priority_Unblock(
156  const Scheduler_Control *scheduler,
157  Thread_Control          *the_thread
158);
159
160Scheduler_Void_or_thread _Scheduler_priority_Change_priority(
161  const Scheduler_Control *scheduler,
162  Thread_Control          *the_thread,
163  Priority_Control         new_priority,
164  bool                     prepend_it
165);
166
167/**
168 *  @brief The specified THREAD yields.
169 *
170 *  This routine is invoked when a thread wishes to voluntarily
171 *  transfer control of the processor to another thread in the queue.
172 *
173 *  This routine will remove the specified THREAD from the ready queue
174 *  and place it immediately at the rear of this chain.  Reset timeslice
175 *  and yield the processor functions both use this routine, therefore if
176 *  reset is true and this is the only thread on the queue then the
177 *  timeslice counter is reset.  The heir THREAD will be updated if the
178 *  running is also the currently the heir.
179 *
180 *  - INTERRUPT LATENCY:
181 *    + ready chain
182 *    + select heir
183 *
184 *  @param[in] scheduler The scheduler instance.
185 *  @param[in,out] the_thread The yielding thread.
186 */
187Scheduler_Void_or_thread _Scheduler_priority_Yield(
188  const Scheduler_Control *scheduler,
189  Thread_Control          *the_thread
190);
191
192/**
193 *  @brief Compare two priorities.
194 *
195 *  This routine compares two priorities.
196 *
197 * @retval >0 for p1 > p2; 0 for p1 == p2; <0 for p1 < p2.
198 */
199int _Scheduler_priority_Priority_compare(
200  Priority_Control   p1,
201  Priority_Control   p2
202);
203
204/**@}*/
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif
211/* end of include file */
Note: See TracBrowser for help on using the repository browser.