source: rtems/cpukit/score/src/threadchangepriority.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 *  Thread Handler / Change Priority
3 *
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/score/isr.h>
18#include <rtems/score/scheduler.h>
19#include <rtems/score/schedulerpriority.h>
20#include <rtems/score/thread.h>
21#include <rtems/score/threadq.h>
22
23void _Thread_Change_priority(
24  Thread_Control   *the_thread,
25  Priority_Control  new_priority,
26  bool              prepend_it
27)
28{
29  ISR_Level      level;
30  States_Control state, original_state;
31
32  /*
33   * Save original state
34   */
35  original_state = the_thread->current_state;
36
37  /*
38   * Set a transient state for the thread so it is pulled off the Ready chains.
39   * This will prevent it from being scheduled no matter what happens in an
40   * ISR.
41   */
42  _Thread_Set_transient( the_thread );
43
44  /*
45   *  Do not bother recomputing all the priority related information if
46   *  we are not REALLY changing priority.
47   */
48 if ( the_thread->current_priority != new_priority )
49    _Thread_Set_priority( the_thread, new_priority );
50
51  _ISR_Disable( level );
52
53  /*
54   *  If the thread has more than STATES_TRANSIENT set, then it is blocked,
55   *  If it is blocked on a thread queue, then we need to requeue it.
56   */
57  state = the_thread->current_state;
58  if ( state != STATES_TRANSIENT ) {
59    /* Only clear the transient state if it wasn't set already */
60    if ( ! _States_Is_transient( original_state ) )
61      the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
62    _ISR_Enable( level );
63    if ( _States_Is_waiting_on_thread_queue( state ) ) {
64      _Thread_queue_Requeue( the_thread->Wait.queue, the_thread );
65    }
66    return;
67  }
68
69  /* Only clear the transient state if it wasn't set already */
70  if ( ! _States_Is_transient( original_state ) ) {
71    /*
72     *  Interrupts are STILL disabled.
73     *  We now know the thread will be in the READY state when we remove
74     *  the TRANSIENT state.  So we have to place it on the appropriate
75     *  Ready Queue with interrupts off.
76     */
77    the_thread->current_state = _States_Clear( STATES_TRANSIENT, state );
78
79    if ( prepend_it )
80      _Scheduler_Enqueue_first( the_thread );
81    else
82      _Scheduler_Enqueue( the_thread );
83  }
84
85  _ISR_Flash( level );
86
87  /*
88   *  We altered the set of thread priorities.  So let's figure out
89   *  who is the heir and if we need to switch to them.
90   */
91  _Scheduler_Schedule();
92
93  if ( !_Thread_Is_executing_also_the_heir() &&
94       _Thread_Executing->is_preemptible )
95    _Thread_Dispatch_necessary = true;
96  _ISR_Enable( level );
97}
Note: See TracBrowser for help on using the repository browser.