source: rtems/cpukit/score/src/schedulerprioritychangepriority.c @ fce900b5

5
Last change on this file since fce900b5 was c597fb1, checked in by Sebastian Huber <sebastian.huber@…>, on 11/09/17 at 15:21:37

score: Optimize scheduler priority updates

Thread priority changes may append or prepend the thread to its priority
group on the scheduler ready queue. Previously, a separate priority
value and a prepend-it flag in the scheduler node were used to propagate
a priority change to the scheduler.

Now, use an append-it bit in the priority control and reduce the plain
priority value to 63 bits.

This change leads to a significant code size reduction (about 25%) of
the SMP schedulers. The negligible increase of the standard priority
scheduler is due to some additional shift operations
(SCHEDULER_PRIORITY_MAP() and SCHEDULER_PRIORITY_UNMAP()).

Before:

text filename

136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o
464 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o

24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o

108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o
292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o
264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o

text filename

280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o
488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o
164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o
328 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o

text filename

24112 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o

text filename

37204 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o

text filename

42236 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o

After:

text filename

136 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleblock.o
272 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimplechangepriority.o

24 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimple.o

108 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleschedule.o
292 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleunblock.o
264 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulersimpleyield.o

text filename

280 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityblock.o
488 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerprioritychangepriority.o
208 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriority.o
164 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityschedule.o
332 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityunblock.o
200 sparc-rtems5/c/erc32/cpukit/score/src/libscore_a-schedulerpriorityyield.o

text filename

18860 arm-rtems5/c/imx7/cpukit/score/src/libscore_a-scheduleredfsmp.o

text filename

28520 sparc-rtems5/c/gr740/cpukit/score/src/libscore_a-scheduleredfsmp.o

text filename

32664 powerpc-rtems5/c/qoriq_e6500_32/cpukit/score/src/libscore_a-scheduleredfsmp.o

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Removes Thread from Thread Queue
5 *
6 * @ingroup ScoreScheduler
7 */
8
9/*
10 *  COPYRIGHT (c) 2011.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/schedulerpriorityimpl.h>
23
24void _Scheduler_priority_Update_priority(
25  const Scheduler_Control *scheduler,
26  Thread_Control          *the_thread,
27  Scheduler_Node          *node
28)
29{
30  Scheduler_priority_Context *context;
31  Scheduler_priority_Node    *the_node;
32  unsigned int                new_priority;
33  unsigned int                unmapped_priority;
34
35  if ( !_Thread_Is_ready( the_thread ) ) {
36    /* Nothing to do */
37    return;
38  }
39
40  the_node = _Scheduler_priority_Node_downcast( node );
41  new_priority = (unsigned int)
42    _Scheduler_Node_get_priority( &the_node->Base );
43  unmapped_priority = SCHEDULER_PRIORITY_UNMAP( new_priority );
44
45  if ( unmapped_priority == the_node->Ready_queue.current_priority ) {
46    /* Nothing to do */
47    return;
48  }
49
50  context = _Scheduler_priority_Get_context( scheduler );
51
52  _Scheduler_priority_Ready_queue_extract(
53    &the_thread->Object.Node,
54    &the_node->Ready_queue,
55    &context->Bit_map
56  );
57
58  _Scheduler_priority_Ready_queue_update(
59    &the_node->Ready_queue,
60    unmapped_priority,
61    &context->Bit_map,
62    &context->Ready[ 0 ]
63  );
64
65  if ( SCHEDULER_PRIORITY_IS_APPEND( new_priority ) ) {
66    _Scheduler_priority_Ready_queue_enqueue(
67      &the_thread->Object.Node,
68      &the_node->Ready_queue,
69      &context->Bit_map
70    );
71  } else {
72    _Scheduler_priority_Ready_queue_enqueue_first(
73      &the_thread->Object.Node,
74      &the_node->Ready_queue,
75      &context->Bit_map
76    );
77  }
78
79  _Scheduler_priority_Schedule_body( scheduler, the_thread, false );
80}
Note: See TracBrowser for help on using the repository browser.