1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/**
* @file
*
* @brief Scheduler EDF Release Job
* @ingroup ScoreScheduler
*/
/*
* Copyright (C) 2011 Petr Benes.
* Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/score/scheduleredfimpl.h>
static bool _Scheduler_EDF_Release_job_filter(
Thread_Control *the_thread,
Priority_Control *new_priority_p,
void *arg
)
{
Scheduler_EDF_Node *node;
Priority_Control current_priority;
Priority_Control new_priority;
node = _Scheduler_EDF_Thread_get_node( the_thread );
current_priority = _Thread_Get_priority( the_thread );
new_priority = *new_priority_p;
node->current_priority = new_priority;
the_thread->real_priority = new_priority;
return _Thread_Priority_less_than( current_priority, new_priority )
|| !_Thread_Owns_resources( the_thread );
}
Thread_Control *_Scheduler_EDF_Release_job(
const Scheduler_Control *scheduler,
Thread_Control *the_thread,
uint64_t deadline
)
{
return _Thread_Apply_priority(
the_thread,
deadline,
NULL,
_Scheduler_EDF_Release_job_filter,
true
);
}
static bool _Scheduler_EDF_Cancel_job_filter(
Thread_Control *the_thread,
Priority_Control *new_priority_p,
void *arg
)
{
Scheduler_EDF_Node *node;
Priority_Control current_priority;
Priority_Control new_priority;
node = _Scheduler_EDF_Thread_get_node( the_thread );
current_priority = _Thread_Get_priority( the_thread );
new_priority = node->background_priority;
node->current_priority = new_priority;
the_thread->real_priority = new_priority;
return _Thread_Priority_less_than( current_priority, new_priority )
|| !_Thread_Owns_resources( the_thread );
}
Thread_Control *_Scheduler_EDF_Cancel_job(
const Scheduler_Control *scheduler,
Thread_Control *the_thread
)
{
return _Thread_Apply_priority(
the_thread,
0,
NULL,
_Scheduler_EDF_Cancel_job_filter,
true
);
}
|