source: rtems/cpukit/score/src/threadchangepriority.c @ 3250664

4.115
Last change on this file since 3250664 was 3250664, checked in by Joel Sherrill <joel.sherrill@…>, on 07/15/14 at 17:37:36

Thread Queue: Merge discipline subroutines into main methods

There was a lot of duplication between the discipline subroutines.
With the transition to RBTrees for priority discipline, there were
only a few lines of source code manipulating the data structure
for FIFO and priority. Thus is made sense to fold these back
into the main methods.

As part of doing this all of the tests for discipline were changed
to be in the same order.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Changes the Priority of a Thread
5 *
6 * @ingroup ScoreThread
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2014.
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/threadimpl.h>
23#include <rtems/score/schedulerimpl.h>
24#include <rtems/score/threadqimpl.h>
25
26void _Thread_Change_priority(
27  Thread_Control   *the_thread,
28  Priority_Control  new_priority,
29  bool              prepend_it
30)
31{
32  /*
33   *  Do not bother recomputing all the priority related information if
34   *  we are not REALLY changing priority.
35   */
36  if ( the_thread->current_priority != new_priority ) {
37    ISR_Level level;
38
39    _ISR_Disable( level );
40
41    the_thread->current_priority = new_priority;
42
43    if ( _States_Is_ready( the_thread->current_state ) ) {
44      _Scheduler_Change_priority(
45        the_thread,
46        new_priority,
47        prepend_it
48      );
49
50      _ISR_Flash( level );
51
52      /*
53       *  We altered the set of thread priorities.  So let's figure out
54       *  who is the heir and if we need to switch to them.
55       */
56      _Scheduler_Schedule( the_thread );
57    } else {
58      _Scheduler_Update_priority( the_thread, new_priority );
59    }
60    _ISR_Enable( level );
61
62    _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
63  }
64}
Note: See TracBrowser for help on using the repository browser.