4.115
Last change
on this file since 6a941e3 was
6a941e3,
checked in by Sebastian Huber <sebastian.huber@…>, on 03/17/15 at 15:24:44
|
score: Fix _Thread_Change_priority()
Atomically update the current priority of a thread and the wait queue.
Serialize the scheduler update in a separate critical section with a
generation number.
New test sptests/spintrcritical23.
Close #2310.
|
-
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 | |
---|
26 | void _Thread_Change_priority( |
---|
27 | Thread_Control *the_thread, |
---|
28 | Priority_Control new_priority, |
---|
29 | bool prepend_it |
---|
30 | ) |
---|
31 | { |
---|
32 | ISR_Level level; |
---|
33 | |
---|
34 | _ISR_Disable( level ); |
---|
35 | |
---|
36 | /* |
---|
37 | * Do not bother recomputing all the priority related information if |
---|
38 | * we are not REALLY changing priority. |
---|
39 | */ |
---|
40 | if ( the_thread->current_priority != new_priority ) { |
---|
41 | uint32_t my_generation = the_thread->priority_generation + 1; |
---|
42 | |
---|
43 | the_thread->current_priority = new_priority; |
---|
44 | the_thread->priority_generation = my_generation; |
---|
45 | |
---|
46 | _Thread_queue_Requeue( the_thread->Wait.queue, the_thread ); |
---|
47 | |
---|
48 | _ISR_Flash( level ); |
---|
49 | |
---|
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 | } |
---|
61 | } |
---|
62 | |
---|
63 | _ISR_Enable( level ); |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.