1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Scheduler Priority Unblock |
---|
5 | * @ingroup ScoreScheduler |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Scheduler Handler |
---|
10 | * |
---|
11 | * Copyright (C) 2010 Gedare Bloom. |
---|
12 | * Copyright (C) 2011 On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.com/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #if HAVE_CONFIG_H |
---|
20 | #include "config.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #include <rtems/system.h> |
---|
24 | #include <rtems/score/scheduler.h> |
---|
25 | #include <rtems/score/schedulerpriority.h> |
---|
26 | |
---|
27 | void _Scheduler_priority_Unblock ( |
---|
28 | Thread_Control *the_thread |
---|
29 | ) |
---|
30 | { |
---|
31 | _Scheduler_priority_Ready_queue_enqueue(the_thread); |
---|
32 | |
---|
33 | /* TODO: flash critical section? */ |
---|
34 | |
---|
35 | /* |
---|
36 | * If the thread that was unblocked is more important than the heir, |
---|
37 | * then we have a new heir. This may or may not result in a |
---|
38 | * context switch. |
---|
39 | * |
---|
40 | * Normal case: |
---|
41 | * If the current thread is preemptible, then we need to do |
---|
42 | * a context switch. |
---|
43 | * Pseudo-ISR case: |
---|
44 | * Even if the thread isn't preemptible, if the new heir is |
---|
45 | * a pseudo-ISR system task, we need to do a context switch. |
---|
46 | */ |
---|
47 | if ( the_thread->current_priority < _Thread_Heir->current_priority ) { |
---|
48 | _Thread_Heir = the_thread; |
---|
49 | if ( _Thread_Executing->is_preemptible || |
---|
50 | the_thread->current_priority == 0 ) |
---|
51 | _Thread_Dispatch_necessary = true; |
---|
52 | } |
---|
53 | } |
---|