1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Removes Thread from Thread Queue |
---|
5 | * |
---|
6 | * @ingroup ScoreScheduler |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 2011. |
---|
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/schedulerpriorityimpl.h> |
---|
23 | |
---|
24 | void _Scheduler_priority_Update_priority( |
---|
25 | const Scheduler_Control *scheduler, |
---|
26 | Thread_Control *the_thread, |
---|
27 | Scheduler_Node *node |
---|
28 | ) |
---|
29 | { |
---|
30 | Scheduler_priority_Context *context; |
---|
31 | Scheduler_priority_Node *the_node; |
---|
32 | unsigned int new_priority; |
---|
33 | unsigned int unmapped_priority; |
---|
34 | |
---|
35 | if ( !_Thread_Is_ready( the_thread ) ) { |
---|
36 | /* Nothing to do */ |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | the_node = _Scheduler_priority_Node_downcast( node ); |
---|
41 | new_priority = (unsigned int) |
---|
42 | _Scheduler_Node_get_priority( &the_node->Base ); |
---|
43 | unmapped_priority = SCHEDULER_PRIORITY_UNMAP( new_priority ); |
---|
44 | |
---|
45 | if ( unmapped_priority == the_node->Ready_queue.current_priority ) { |
---|
46 | /* Nothing to do */ |
---|
47 | return; |
---|
48 | } |
---|
49 | |
---|
50 | context = _Scheduler_priority_Get_context( scheduler ); |
---|
51 | |
---|
52 | _Scheduler_priority_Ready_queue_extract( |
---|
53 | &the_thread->Object.Node, |
---|
54 | &the_node->Ready_queue, |
---|
55 | &context->Bit_map |
---|
56 | ); |
---|
57 | |
---|
58 | _Scheduler_priority_Ready_queue_update( |
---|
59 | &the_node->Ready_queue, |
---|
60 | unmapped_priority, |
---|
61 | &context->Bit_map, |
---|
62 | &context->Ready[ 0 ] |
---|
63 | ); |
---|
64 | |
---|
65 | if ( SCHEDULER_PRIORITY_IS_APPEND( new_priority ) ) { |
---|
66 | _Scheduler_priority_Ready_queue_enqueue( |
---|
67 | &the_thread->Object.Node, |
---|
68 | &the_node->Ready_queue, |
---|
69 | &context->Bit_map |
---|
70 | ); |
---|
71 | } else { |
---|
72 | _Scheduler_priority_Ready_queue_enqueue_first( |
---|
73 | &the_thread->Object.Node, |
---|
74 | &the_node->Ready_queue, |
---|
75 | &context->Bit_map |
---|
76 | ); |
---|
77 | } |
---|
78 | |
---|
79 | _Scheduler_priority_Schedule_body( scheduler, the_thread, false ); |
---|
80 | } |
---|