source: rtems/cpukit/score/include/rtems/score/schedulersimplesmp.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.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Simple SMP Scheduler API
5 *
6 * @ingroup ScoreSchedulerSMPSimple
7 */
8
9/*
10 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
11 *
12 *  Copyright (c) 2013 embedded brains GmbH.
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_SCHEDULERSIMPLE_SMP_H
20#define _RTEMS_SCORE_SCHEDULERSIMPLE_SMP_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <rtems/score/scheduler.h>
27#include <rtems/score/schedulerpriority.h>
28#include <rtems/score/schedulersmp.h>
29
30/**
31 * @defgroup ScoreSchedulerSMPSimple Simple Priority SMP Scheduler
32 *
33 * @ingroup ScoreSchedulerSMP
34 *
35 * The Simple Priority SMP Scheduler allocates a processor for the processor
36 * count highest priority ready threads.  The thread priority and position in
37 * the ready chain are the only information to determine the scheduling
38 * decision.  Threads with an allocated processor are in the scheduled chain.
39 * After initialization the scheduled chain has exactly processor count nodes.
40 * Each processor has exactly one allocated thread after initialization.  All
41 * enqueue and extract operations may exchange threads with the scheduled
42 * chain.  One thread will be added and another will be removed.  The scheduled
43 * and ready chain is ordered according to the thread priority order.  The
44 * chain insert operations are O(count of ready threads), thus this scheduler
45 * is unsuitable for most real-time applications.
46 *
47 * The thread preempt mode will be ignored.
48 *
49 * @{
50 */
51
52typedef struct {
53  Scheduler_SMP_Context Base;
54  Chain_Control         Ready;
55} Scheduler_simple_SMP_Context;
56
57/**
58 * @brief Entry points for the Simple SMP Scheduler.
59 */
60#define SCHEDULER_SIMPLE_SMP_ENTRY_POINTS \
61  { \
62    _Scheduler_simple_SMP_Initialize, \
63    _Scheduler_simple_SMP_Schedule, \
64    _Scheduler_simple_SMP_Yield, \
65    _Scheduler_simple_SMP_Block, \
66    _Scheduler_simple_SMP_Unblock, \
67    _Scheduler_simple_SMP_Change_priority, \
68    _Scheduler_simple_SMP_Allocate, \
69    _Scheduler_default_Free, \
70    _Scheduler_default_Update, \
71    _Scheduler_priority_Priority_compare, \
72    _Scheduler_default_Release_job, \
73    _Scheduler_default_Tick, \
74    _Scheduler_simple_SMP_Start_idle, \
75    _Scheduler_default_Get_affinity, \
76    _Scheduler_default_Set_affinity \
77  }
78
79void _Scheduler_simple_SMP_Initialize( const Scheduler_Control *scheduler );
80
81bool _Scheduler_simple_SMP_Allocate(
82  const Scheduler_Control *scheduler,
83  Thread_Control          *the_thread
84);
85
86void _Scheduler_simple_SMP_Block(
87  const Scheduler_Control *scheduler,
88  Thread_Control *thread
89);
90
91void _Scheduler_simple_SMP_Unblock(
92  const Scheduler_Control *scheduler,
93  Thread_Control *thread
94);
95
96void _Scheduler_simple_SMP_Change_priority(
97  const Scheduler_Control *scheduler,
98  Thread_Control          *the_thread,
99  Priority_Control         new_priority,
100  bool                     prepend_it
101);
102
103void _Scheduler_simple_SMP_Yield(
104  const Scheduler_Control *scheduler,
105  Thread_Control *thread
106);
107
108void _Scheduler_simple_SMP_Schedule(
109  const Scheduler_Control *scheduler,
110  Thread_Control *thread
111);
112
113void _Scheduler_simple_SMP_Start_idle(
114  const Scheduler_Control *scheduler,
115  Thread_Control *thread,
116  Per_CPU_Control *cpu
117);
118
119/** @} */
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126/* end of include file */
Note: See TracBrowser for help on using the repository browser.