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

4.115
Last change on this file since b8a5abf was b8a5abf, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 26, 2015 at 9:33:36 AM

score: Update _Thread_Heir only if necessary

Previously, the _Thread_Heir was updated unconditionally in case a new
heir was determined. The _Thread_Dispatch_necessary was only updated in
case the executing thread was preemptible or an internal thread was
unblocked. Change this to update the _Thread_Heir and
_Thread_Dispatch_necessary only in case the currently selected heir
thread is preemptible or a dispatch is forced. Move the schedule
decision into the change priority operation and use the schedule
operation only in rtems_task_mode() in case preemption is enabled or an
ASR dispatch is necessary. This is a behaviour change. Previously, the
RTEMS_NO_PREEMPT also prevented signal delivery in certain cases (not
always). Now, signal delivery is no longer influenced by
RTEMS_NO_PREEMPT. Since the currently selected heir thread is used to
determine if a new heir is chosen, non-preemptible heir threads
currently not executing now prevent a new heir. This may have an
application impact, see change test tm04. Document this change in sp04.

Update #2273.

  • Property mode set to 100644
File size: 1.2 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    } else {
50      _Scheduler_Update_priority( the_thread, new_priority );
51    }
52
53    _ISR_Enable( level );
54
55    _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
56  }
57}
Note: See TracBrowser for help on using the repository browser.