1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Scheduler EDF Release Job |
---|
5 | * @ingroup ScoreScheduler |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * Copyright (C) 2011 Petr Benes. |
---|
10 | * Copyright (C) 2011 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/scheduleredfimpl.h> |
---|
22 | |
---|
23 | static bool _Scheduler_EDF_Release_job_filter( |
---|
24 | Thread_Control *the_thread, |
---|
25 | Priority_Control *new_priority_p, |
---|
26 | void *arg |
---|
27 | ) |
---|
28 | { |
---|
29 | Scheduler_EDF_Node *node; |
---|
30 | Priority_Control current_priority; |
---|
31 | Priority_Control new_priority; |
---|
32 | |
---|
33 | node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
34 | |
---|
35 | current_priority = _Thread_Get_priority( the_thread ); |
---|
36 | new_priority = *new_priority_p; |
---|
37 | |
---|
38 | node->current_priority = new_priority; |
---|
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 | Thread_Control *_Scheduler_EDF_Release_job( |
---|
46 | const Scheduler_Control *scheduler, |
---|
47 | Thread_Control *the_thread, |
---|
48 | uint64_t deadline |
---|
49 | ) |
---|
50 | { |
---|
51 | return _Thread_Apply_priority( |
---|
52 | the_thread, |
---|
53 | deadline, |
---|
54 | NULL, |
---|
55 | _Scheduler_EDF_Release_job_filter, |
---|
56 | true |
---|
57 | ); |
---|
58 | } |
---|
59 | |
---|
60 | static bool _Scheduler_EDF_Cancel_job_filter( |
---|
61 | Thread_Control *the_thread, |
---|
62 | Priority_Control *new_priority_p, |
---|
63 | void *arg |
---|
64 | ) |
---|
65 | { |
---|
66 | Scheduler_EDF_Node *node; |
---|
67 | Priority_Control current_priority; |
---|
68 | Priority_Control new_priority; |
---|
69 | |
---|
70 | node = _Scheduler_EDF_Thread_get_node( the_thread ); |
---|
71 | |
---|
72 | current_priority = _Thread_Get_priority( the_thread ); |
---|
73 | new_priority = node->background_priority; |
---|
74 | |
---|
75 | node->current_priority = new_priority; |
---|
76 | the_thread->real_priority = new_priority; |
---|
77 | |
---|
78 | return _Thread_Priority_less_than( current_priority, new_priority ) |
---|
79 | || !_Thread_Owns_resources( the_thread ); |
---|
80 | } |
---|
81 | |
---|
82 | Thread_Control *_Scheduler_EDF_Cancel_job( |
---|
83 | const Scheduler_Control *scheduler, |
---|
84 | Thread_Control *the_thread |
---|
85 | ) |
---|
86 | { |
---|
87 | return _Thread_Apply_priority( |
---|
88 | the_thread, |
---|
89 | 0, |
---|
90 | NULL, |
---|
91 | _Scheduler_EDF_Cancel_job_filter, |
---|
92 | true |
---|
93 | ); |
---|
94 | } |
---|