source: rtems/cpukit/score/include/rtems/score/schedulerprioritysmp.h @ f39f667a

4.115
Last change on this file since f39f667a was f39f667a, checked in by Sebastian Huber <sebastian.huber@…>, on 05/14/14 at 11:50:48

score: Simplify _Thread_Change_priority()

The function to change a thread priority was too complex. Simplify it
with a new scheduler operation. This increases the average case
performance due to the simplified logic. The interrupt disabled
critical section is a bit prolonged since now the extract, update and
enqueue steps are executed atomically. This should however not impact
the worst-case interrupt latency since at least for the Deterministic
Priority Scheduler this sequence can be carried out with a wee bit of
instructions and no loops.

Add _Scheduler_Change_priority() to replace the sequence of

  • _Thread_Set_transient(),
  • _Scheduler_Extract(),
  • _Scheduler_Enqueue(), and
  • _Scheduler_Enqueue_first().

Delete STATES_TRANSIENT, _States_Is_transient() and
_Thread_Set_transient() since this state is now superfluous.

With this change it is possible to get rid of the
SCHEDULER_SMP_NODE_IN_THE_AIR state. This considerably simplifies the
implementation of the new SMP locking protocols.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreSchedulerPrioritySMP
5 *
6 * @brief Deterministic Priority SMP Scheduler API
7 */
8
9/*
10 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#ifndef _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H
24#define _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H
25
26#include <rtems/score/scheduler.h>
27#include <rtems/score/schedulerpriority.h>
28#include <rtems/score/schedulersmp.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif /* __cplusplus */
33
34/**
35 * @defgroup ScoreSchedulerPrioritySMP Deterministic Priority SMP Scheduler
36 *
37 * @ingroup ScoreSchedulerSMP
38 *
39 * This is an implementation of the global fixed priority scheduler (G-FP).  It
40 * uses one ready chain per priority to ensure constant time insert operations.
41 * The scheduled chain uses linear insert operations and has at most processor
42 * count entries.  Since the processor and priority count are constants all
43 * scheduler operations complete in a bounded execution time.
44 *
45 * The thread preempt mode will be ignored.
46 *
47 * @{
48 */
49
50/**
51 * @brief Scheduler context specialization for Deterministic Priority SMP
52 * schedulers.
53 */
54typedef struct {
55  Scheduler_SMP_Context    Base;
56  Priority_bit_map_Control Bit_map;
57  Chain_Control            Ready[ RTEMS_ZERO_LENGTH_ARRAY ];
58} Scheduler_priority_SMP_Context;
59
60/**
61 * @brief Scheduler node specialization for Deterministic Priority SMP
62 * schedulers.
63 */
64typedef struct {
65  /**
66   * @brief SMP scheduler node.
67   */
68  Scheduler_SMP_Node Base;
69
70  /**
71   * @brief The associated ready queue of this node.
72   */
73  Scheduler_priority_Ready_queue Ready_queue;
74} Scheduler_priority_SMP_Node;
75
76/**
77 * @brief Entry points for the Priority SMP Scheduler.
78 */
79#define SCHEDULER_PRIORITY_SMP_ENTRY_POINTS \
80  { \
81    _Scheduler_priority_SMP_Initialize, \
82    _Scheduler_priority_SMP_Schedule, \
83    _Scheduler_priority_SMP_Yield, \
84    _Scheduler_priority_SMP_Block, \
85    _Scheduler_priority_SMP_Unblock, \
86    _Scheduler_priority_SMP_Change_priority, \
87    _Scheduler_priority_SMP_Allocate, \
88    _Scheduler_default_Free, \
89    _Scheduler_priority_SMP_Update, \
90    _Scheduler_priority_Priority_compare, \
91    _Scheduler_default_Release_job, \
92    _Scheduler_default_Tick, \
93    _Scheduler_priority_SMP_Start_idle, \
94    _Scheduler_default_Get_affinity, \
95    _Scheduler_default_Set_affinity \
96  }
97
98void _Scheduler_priority_SMP_Initialize( const Scheduler_Control *scheduler );
99
100bool _Scheduler_priority_SMP_Allocate(
101  const Scheduler_Control *scheduler,
102  Thread_Control *thread
103);
104
105void _Scheduler_priority_SMP_Schedule(
106  const Scheduler_Control *scheduler,
107  Thread_Control *thread
108);
109
110void _Scheduler_priority_SMP_Block(
111  const Scheduler_Control *scheduler,
112  Thread_Control *thread
113);
114
115void _Scheduler_priority_SMP_Unblock(
116  const Scheduler_Control *scheduler,
117  Thread_Control *thread
118);
119
120void _Scheduler_priority_SMP_Change_priority(
121  const Scheduler_Control *scheduler,
122  Thread_Control          *the_thread,
123  Priority_Control         new_priority,
124  bool                     prepend_it
125);
126
127void _Scheduler_priority_SMP_Update(
128  const Scheduler_Control *scheduler,
129  Thread_Control *thread
130);
131
132void _Scheduler_priority_SMP_Yield(
133  const Scheduler_Control *scheduler,
134  Thread_Control *thread
135);
136
137void _Scheduler_priority_SMP_Start_idle(
138  const Scheduler_Control *scheduler,
139  Thread_Control *thread,
140  Per_CPU_Control *cpu
141);
142
143/** @} */
144
145#ifdef __cplusplus
146}
147#endif /* __cplusplus */
148
149#endif /* _RTEMS_SCORE_SCHEDULERPRIORITYSMP_H */
Note: See TracBrowser for help on using the repository browser.