source: rtems/cpukit/score/include/rtems/score/schedulersimpleimpl.h @ 89f8eab5

4.115
Last change on this file since 89f8eab5 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: 2.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines Associated with the Manipulation of the
5 * Priority-Based Scheduling Structures
6 *
7 * This inline file contains all of the inlined routines associated with
8 * the manipulation of the priority-based scheduling structures.
9 */
10
11/*
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_SCHEDULERSIMPLEIMPL_H
20#define _RTEMS_SCORE_SCHEDULERSIMPLEIMPL_H
21
22#include <rtems/score/schedulersimple.h>
23#include <rtems/score/chainimpl.h>
24#include <rtems/score/schedulerimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/**
31 * @addtogroup ScoreSchedulerSimple
32 */
33/**@{**/
34
35RTEMS_INLINE_ROUTINE Scheduler_simple_Context *
36  _Scheduler_simple_Get_context( const Scheduler_Control *scheduler )
37{
38  return (Scheduler_simple_Context *) _Scheduler_Get_context( scheduler );
39}
40
41RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_lifo_order(
42  const Chain_Node *to_insert,
43  const Chain_Node *next
44)
45{
46  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
47  const Thread_Control *thread_next = (const Thread_Control *) next;
48
49  return thread_to_insert->current_priority <= thread_next->current_priority;
50}
51
52RTEMS_INLINE_ROUTINE bool _Scheduler_simple_Insert_priority_fifo_order(
53  const Chain_Node *to_insert,
54  const Chain_Node *next
55)
56{
57  const Thread_Control *thread_to_insert = (const Thread_Control *) to_insert;
58  const Thread_Control *thread_next = (const Thread_Control *) next;
59
60  return thread_to_insert->current_priority < thread_next->current_priority;
61}
62
63RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_lifo(
64  Chain_Control *chain,
65  Thread_Control *to_insert
66)
67{
68  _Chain_Insert_ordered_unprotected(
69    chain,
70    &to_insert->Object.Node,
71    _Scheduler_simple_Insert_priority_lifo_order
72  );
73}
74
75RTEMS_INLINE_ROUTINE void _Scheduler_simple_Insert_priority_fifo(
76  Chain_Control *chain,
77  Thread_Control *to_insert
78)
79{
80  _Chain_Insert_ordered_unprotected(
81    chain,
82    &to_insert->Object.Node,
83    _Scheduler_simple_Insert_priority_fifo_order
84  );
85}
86
87RTEMS_INLINE_ROUTINE void _Scheduler_simple_Extract(
88  const Scheduler_Control *scheduler,
89  Thread_Control          *the_thread
90)
91{
92  (void) scheduler;
93
94  _Chain_Extract_unprotected( &the_thread->Object.Node );
95}
96
97RTEMS_INLINE_ROUTINE void _Scheduler_simple_Schedule_body(
98  const Scheduler_Control *scheduler,
99  Thread_Control          *the_thread,
100  bool                     force_dispatch
101)
102{
103  Scheduler_simple_Context *context =
104    _Scheduler_simple_Get_context( scheduler );
105  Thread_Control *heir = (Thread_Control *) _Chain_First( &context->Ready );
106
107  ( void ) the_thread;
108
109  _Scheduler_Update_heir( heir, force_dispatch );
110}
111
112/** @} */
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
119/* end of include file */
Note: See TracBrowser for help on using the repository browser.