source: rtems/cpukit/score/include/rtems/score/scheduler.h @ 1ccb64e1

4.115
Last change on this file since 1ccb64e1 was 1ccb64e1, checked in by Sebastian Huber <sebastian.huber@…>, on 06/06/13 at 13:28:41

scheduler: Add start idle thread operation

Add and use _Scheduler_Start_idle().

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/**
2 *  @file  rtems/score/scheduler.h
3 *
4 *  @brief Constants and Structures Associated with the Scheduler
5 *
6 *  This include file contains all the constants and structures associated
7 *  with the scheduler.
8 */
9
10/*
11 *  Copyright (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.com/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_SCHEDULER_H
20#define _RTEMS_SCORE_SCHEDULER_H
21
22#include <rtems/score/percpu.h>
23#include <rtems/score/chain.h>
24#include <rtems/score/priority.h>
25#include <rtems/score/prioritybitmap.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 *  @defgroup ScoreScheduler Scheduler Handler
33 *
34 *  @ingroup Score
35 *
36 *  This handler encapsulates functionality related to managing sets of threads
37 *  that are ready for execution.
38 */
39/**@{*/
40
41/**
42 * function jump table that holds pointers to the functions that
43 * implement specific schedulers.
44 */
45typedef struct {
46  /** Implements the scheduling decision logic (policy). */
47  void ( *initialize )(void);
48
49  /** Implements the scheduling decision logic (policy). */
50  void ( *schedule )(void);
51
52  /** Voluntarily yields the processor per the scheduling policy. */
53  void ( *yield )(void);
54
55  /** Removes the given thread from scheduling decisions. */
56  void ( *block )(Thread_Control *);
57
58  /** Adds the given thread to scheduling decisions. */
59  void ( *unblock )(Thread_Control *);
60
61  /** allocates the scheduler field of the given thread */
62  void * ( *allocate )(Thread_Control *);
63
64  /** frees the scheduler field of the given thread */
65  void ( *free )(Thread_Control *);
66
67  /** updates the scheduler field of the given thread -- primarily used
68   * when changing the thread's priority. */
69  void ( *update )(Thread_Control *);
70
71  /** enqueue a thread as the last of its priority group */
72  void ( *enqueue )(Thread_Control *);
73
74  /** enqueue a thread as the first of its priority group */
75  void ( *enqueue_first )(Thread_Control *);
76
77  /** extract a thread from the ready set */
78  void ( *extract )(Thread_Control *);
79
80  /**
81   * Compares two priorities (returns >0 for higher priority, 0 for equal
82   * and <0 for lower priority).
83   */
84  int ( *priority_compare )(Priority_Control, Priority_Control);
85
86  /** This routine is called upon release of a new job. */
87  void ( *release_job ) (Thread_Control *, uint32_t);
88
89  /** perform scheduler update actions required at each clock tick */
90  void ( *tick )(void);
91
92  /**
93   * @brief Starts the idle thread for a particular processor.
94   *
95   * @see _Scheduler_Start_idle().
96   */
97  void ( *start_idle )( Thread_Control *thread, Per_CPU_Control *processor );
98} Scheduler_Operations;
99
100/**
101 * This is the structure used to manage the scheduler.
102 */
103typedef struct {
104  /**
105   *  This points to the data structure used to manage the ready set of
106   *  tasks. The pointer varies based upon the type of
107   *  ready queue required by the scheduler.
108   */
109  void                   *information;
110
111  /** The jump table for scheduler-specific functions */
112  Scheduler_Operations    Operations;
113} Scheduler_Control;
114
115/**
116 *  The _Scheduler holds the structures used to manage the
117 *  scheduler.
118 *
119 * @note Can we make this per-cpu? then _Scheduler will be a macro.
120 *
121 * @note This is instantiated and initialized in confdefs.h.
122 */
123extern Scheduler_Control  _Scheduler;
124
125/**
126 * Macro testing whether @a p1 has lower priority than @a p2
127 * in the intuitive sense of priority.
128 */
129#define _Scheduler_Is_priority_lower_than( _p1, _p2 ) \
130  (_Scheduler_Priority_compare(_p1,_p2) < 0)
131
132/**
133 * Macro testing whether @a p1 has higher priority than @a p2
134 * in the intuitive sense of priority.
135 */
136#define _Scheduler_Is_priority_higher_than( _p1, _p2 ) \
137  (_Scheduler_Priority_compare(_p1,_p2) > 0)
138
139/**
140 *  @brief Initializes the scheduler to the policy chosen by the user.
141 *
142 *  This routine initializes the scheduler to the policy chosen by the user
143 *  through confdefs, or to the priority scheduler with ready chains by
144 *  default.
145 */
146void _Scheduler_Handler_initialization( void );
147
148/**
149 * @brief Unblocks the thread.
150 *
151 * @param[in/out] thread An idle thread.
152 * @param[in] processor This parameter is unused.
153 */
154void _Scheduler_default_Start_idle(
155  Thread_Control  *thread,
156  Per_CPU_Control *processor
157);
158
159#ifndef __RTEMS_APPLICATION__
160#include <rtems/score/scheduler.inl>
161#endif
162
163/**@}*/
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif
170/* end of include file */
Note: See TracBrowser for help on using the repository browser.