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 | Scheduler_Void_or_thread _Scheduler_priority_Update_priority( |
---|
25 | const Scheduler_Control *scheduler, |
---|
26 | Thread_Control *the_thread |
---|
27 | ) |
---|
28 | { |
---|
29 | Scheduler_priority_Context *context; |
---|
30 | Scheduler_priority_Node *node; |
---|
31 | unsigned int priority; |
---|
32 | bool prepend_it; |
---|
33 | |
---|
34 | if ( !_Thread_Is_ready( the_thread ) ) { |
---|
35 | /* Nothing to do */ |
---|
36 | SCHEDULER_RETURN_VOID_OR_NULL; |
---|
37 | } |
---|
38 | |
---|
39 | node = _Scheduler_priority_Thread_get_node( the_thread ); |
---|
40 | priority = (unsigned int ) |
---|
41 | _Scheduler_Node_get_priority( &node->Base, &prepend_it ); |
---|
42 | |
---|
43 | if ( priority == node->Ready_queue.current_priority ) { |
---|
44 | /* Nothing to do */ |
---|
45 | SCHEDULER_RETURN_VOID_OR_NULL; |
---|
46 | } |
---|
47 | |
---|
48 | context = _Scheduler_priority_Get_context( scheduler ); |
---|
49 | |
---|
50 | _Scheduler_priority_Ready_queue_extract( |
---|
51 | &the_thread->Object.Node, |
---|
52 | &node->Ready_queue, |
---|
53 | &context->Bit_map |
---|
54 | ); |
---|
55 | |
---|
56 | _Scheduler_priority_Ready_queue_update( |
---|
57 | &node->Ready_queue, |
---|
58 | priority, |
---|
59 | &context->Bit_map, |
---|
60 | &context->Ready[ 0 ] |
---|
61 | ); |
---|
62 | |
---|
63 | if ( prepend_it ) { |
---|
64 | _Scheduler_priority_Ready_queue_enqueue_first( |
---|
65 | &the_thread->Object.Node, |
---|
66 | &node->Ready_queue, |
---|
67 | &context->Bit_map |
---|
68 | ); |
---|
69 | } else { |
---|
70 | _Scheduler_priority_Ready_queue_enqueue( |
---|
71 | &the_thread->Object.Node, |
---|
72 | &node->Ready_queue, |
---|
73 | &context->Bit_map |
---|
74 | ); |
---|
75 | } |
---|
76 | |
---|
77 | _Scheduler_priority_Schedule_body( scheduler, the_thread, false ); |
---|
78 | |
---|
79 | SCHEDULER_RETURN_VOID_OR_NULL; |
---|
80 | } |
---|