1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Set Thread Priority |
---|
5 | * @ingroup ScoreThread |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2011. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/threadimpl.h> |
---|
22 | |
---|
23 | static bool _Thread_Set_priority_filter( |
---|
24 | Thread_Control *the_thread, |
---|
25 | Priority_Control *new_priority_ptr, |
---|
26 | void *arg |
---|
27 | ) |
---|
28 | { |
---|
29 | Priority_Control current_priority; |
---|
30 | Priority_Control new_priority; |
---|
31 | Priority_Control *old_priority_ptr; |
---|
32 | |
---|
33 | current_priority = the_thread->current_priority; |
---|
34 | new_priority = *new_priority_ptr; |
---|
35 | |
---|
36 | old_priority_ptr = arg; |
---|
37 | *old_priority_ptr = current_priority; |
---|
38 | |
---|
39 | the_thread->real_priority = new_priority; |
---|
40 | |
---|
41 | return _Thread_Priority_less_than( current_priority, new_priority ) |
---|
42 | || !_Thread_Owns_resources( the_thread ); |
---|
43 | } |
---|
44 | |
---|
45 | void _Thread_Set_priority( |
---|
46 | Thread_Control *the_thread, |
---|
47 | Priority_Control new_priority, |
---|
48 | Priority_Control *old_priority, |
---|
49 | bool prepend_it |
---|
50 | ) |
---|
51 | { |
---|
52 | _Thread_Change_priority( |
---|
53 | the_thread, |
---|
54 | new_priority, |
---|
55 | old_priority, |
---|
56 | _Thread_Set_priority_filter, |
---|
57 | prepend_it |
---|
58 | ); |
---|
59 | } |
---|