summaryrefslogtreecommitdiffstats
path: root/cpukit/score/inline/rtems/score/scheduler.inl
blob: 81290eb84ac575bdc06bef398dd41fd096769802 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/** 
 *  @file  rtems/score/scheduler.inl
 *
 *  This inline file contains all of the inlined routines associated with
 *  the manipulation of the scheduler.
 */

/*
 *  Copyright (C) 2010 Gedare Bloom.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#ifndef _RTEMS_SCORE_SCHEDULER_H
# error "Never use <rtems/score/scheduler.inl> directly; include <rtems/score/scheduler.h> instead."
#endif

#ifndef _RTEMS_SCORE_SCHEDULER_INL
#define _RTEMS_SCORE_SCHEDULER_INL

/**
 *  @addtogroup ScoreScheduler
 * @{
 */

/**
 * The preferred method to add a new scheduler is to define the jump table 
 * entries and add a case to the _Scheduler_Initialize routine. 
 *
 * Generic scheduling implementations that rely on the ready queue only can 
 * be found in the _Scheduler_queue_XXX functions.
 *
 */

/* Passing the Scheduler_Control* to these functions allows for multiple 
 * scheduler's to exist simultaneously, which could be useful on an SMP 
 * system.  Then remote Schedulers may be accessible.  How to protect such 
 * accesses remains an open problem.
 */

/** @brief _Scheduler_Schedule
 *
 *  This kernel routine implements the scheduling decision logic for 
 *  @a the_scheduler. It does NOT dispatch.
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Schedule(
    Scheduler_Control *the_scheduler 
)
{
  the_scheduler->Operations.schedule( the_scheduler );
}

/** @brief _Scheduler_Yield
 *
 *  This routine is invoked when a thread wishes to voluntarily
 *  transfer control of the processor to another thread. This routine
 *  always operates on the scheduler that 'owns' the currently executing
 *  thread.
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Yield( void )
{
  _Scheduler.Operations.yield( &_Scheduler );
}

/** @brief _Scheduler_Block
 *
 *  This routine removes @a the_thread from the scheduling decision for 
 *  @a the_scheduler. The primary task is to remove the thread from the 
 *  ready queue.  It performs any necessary schedulering operations 
 *  including the selection of a new heir thread.
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Block( 
    Scheduler_Control *the_scheduler,
    Thread_Control    *the_thread 
)
{
  the_scheduler->Operations.block( the_scheduler, the_thread );
}

/** @brief _Scheduler_Unblock
 *
 *  This routine adds @a the_thread to the scheduling decision for 
 *  @a the_scheduler.  The primary task is to add the thread to the
 *  ready queue per the schedulering policy and update any appropriate 
 *  scheduling variables, for example the heir thread.
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Unblock(
    Scheduler_Control *the_scheduler,
    Thread_Control    *the_thread 
)
{
  the_scheduler->Operations.unblock( the_scheduler, the_thread );
}

/** @brief _Scheduler_Thread_scheduler_allocate
 *
 * This routine allocates @a the_thread->scheduler
 */
RTEMS_INLINE_ROUTINE void* _Scheduler_Thread_scheduler_allocate( 
  Scheduler_Control *the_scheduler,
  Thread_Control    *the_thread
)
{
  return 
    the_scheduler->Operations.scheduler_allocate( the_scheduler, the_thread );
}

/** @brief _Scheduler_Thread_scheduler_free
 *
 * This routine frees @a the_thread->scheduler
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_free( 
  Scheduler_Control *the_scheduler,
  Thread_Control    *the_thread
)
{
  return the_scheduler->Operations.scheduler_free( the_scheduler, the_thread );
}

/** @brief _Scheduler_Thread_scheduler_update
 *
 * This routine updates @a the_thread->scheduler
 */
RTEMS_INLINE_ROUTINE void _Scheduler_Thread_scheduler_update( 
  Scheduler_Control *the_scheduler,
  Thread_Control    *the_thread
)
{
  the_scheduler->Operations.scheduler_update( the_scheduler, the_thread );
}

/**@}*/

#endif
/* end of include file */