source:
rtems/cpukit/score/src/threadchangepriority.c
@
6a941e3
Last change on this file since 6a941e3 was 6a941e3, checked in by Sebastian Huber <sebastian.huber@…>, on 03/17/15 at 15:24:44 | |
---|---|
|
|
File size: 1.4 KB |
Rev | Line | |
---|---|---|
[1b475860] | 1 | /** |
2 | * @file | |
3 | * | |
4 | * @brief Changes the Priority of a Thread | |
[05df0a8] | 5 | * |
[1b475860] | 6 | * @ingroup ScoreThread |
7 | */ | |
8 | ||
9 | /* | |
[3250664] | 10 | * COPYRIGHT (c) 1989-2014. |
[05df0a8] | 11 | * On-Line Applications Research Corporation (OAR). |
12 | * | |
13 | * The license and distribution terms for this file may be | |
[dcf3687] | 14 | * found in the file LICENSE in this distribution or at |
[c499856] | 15 | * http://www.rtems.org/license/LICENSE. |
[05df0a8] | 16 | */ |
17 | ||
[a8eed23] | 18 | #if HAVE_CONFIG_H |
19 | #include "config.h" | |
20 | #endif | |
21 | ||
[5618c37a] | 22 | #include <rtems/score/threadimpl.h> |
[c6e21ee1] | 23 | #include <rtems/score/schedulerimpl.h> |
[a112364] | 24 | #include <rtems/score/threadqimpl.h> |
[05df0a8] | 25 | |
26 | void _Thread_Change_priority( | |
27 | Thread_Control *the_thread, | |
28 | Priority_Control new_priority, | |
[484a769] | 29 | bool prepend_it |
[05df0a8] | 30 | ) |
31 | { | |
[6a941e3] | 32 | ISR_Level level; |
33 | ||
34 | _ISR_Disable( level ); | |
35 | ||
[96d0b64] | 36 | /* |
37 | * Do not bother recomputing all the priority related information if | |
38 | * we are not REALLY changing priority. | |
39 | */ | |
[f39f667a] | 40 | if ( the_thread->current_priority != new_priority ) { |
[6a941e3] | 41 | uint32_t my_generation = the_thread->priority_generation + 1; |
[f39f667a] | 42 | |
43 | the_thread->current_priority = new_priority; | |
[6a941e3] | 44 | the_thread->priority_generation = my_generation; |
[f39f667a] | 45 | |
[6a941e3] | 46 | _Thread_queue_Requeue( the_thread->Wait.queue, the_thread ); |
[b8a5abf] | 47 | |
[6a941e3] | 48 | _ISR_Flash( level ); |
[96d0b64] | 49 | |
[6a941e3] | 50 | if ( the_thread->priority_generation == my_generation ) { |
51 | if ( _States_Is_ready( the_thread->current_state ) ) { | |
52 | _Scheduler_Change_priority( | |
53 | the_thread, | |
54 | new_priority, | |
55 | prepend_it | |
56 | ); | |
57 | } else { | |
58 | _Scheduler_Update_priority( the_thread, new_priority ); | |
59 | } | |
60 | } | |
[d9aca5f5] | 61 | } |
[6a941e3] | 62 | |
63 | _ISR_Enable( level ); | |
[05df0a8] | 64 | } |
Note: See TracBrowser
for help on using the repository browser.