Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FlightOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
FlightOS
Commits
0ada692d
Commit
0ada692d
authored
Sep 18, 2019
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
have to include new task list in EDF schedulability
parent
06c8b14a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
kernel/sched/edf.c
+120
-34
120 additions, 34 deletions
kernel/sched/edf.c
tools/testing/unittest/edf/edf_test.c
+28
-9
28 additions, 9 deletions
tools/testing/unittest/edf/edf_test.c
with
148 additions
and
43 deletions
kernel/sched/edf.c
+
120
−
34
View file @
0ada692d
...
...
@@ -647,6 +647,11 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
ktime
uh
,
ut
,
f1
;
ktime
sh
=
0
,
st
=
0
;
ktime
stmin
=
0x7fffffffffffffULL
;
ktime
shmin
=
0x7fffffffffffffULL
;
struct
task_struct
*
t0
=
NULL
;
struct
task_struct
*
tsk
=
NULL
;
struct
task_struct
*
tmp
;
...
...
@@ -717,11 +722,65 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
* be used before the deadline
*/
sh
=
h
*
t0
->
attr
.
wcet
*
t0
->
attr
.
deadline_rel
/
t0
->
attr
.
period
;
if
(
sh
<
shmin
)
shmin
=
sh
;
uh
=
uh
-
sh
;
printk
(
"%s UH: %lld, UT: %lld
\n
"
,
t0
->
name
,
ktime_to_us
(
uh
),
ktime_to_us
(
ut
));
printk
(
"%s SH: %lld, ST: %lld
\n
"
,
t0
->
name
,
ktime_to_us
(
sh
),
ktime_to_us
(
st
));
/* add all in new */
if
(
!
list_empty
(
&
tq
->
new
))
{
list_for_each_entry_safe
(
tsk
,
tmp
,
&
tq
->
new
,
node
)
{
if
(
tsk
==
t0
)
continue
;
if
(
tsk
->
attr
.
policy
!=
SCHED_EDF
)
continue
;
u
+=
(
double
)
(
int32_t
)
tsk
->
attr
.
wcet
/
(
double
)
(
int32_t
)
tsk
->
attr
.
period
;
if
(
tsk
->
attr
.
deadline_rel
<=
t0
->
attr
.
deadline_rel
)
{
/* slots before deadline of T0 */
sh
=
h
*
tsk
->
attr
.
wcet
*
t0
->
attr
.
deadline_rel
/
tsk
->
attr
.
period
;
if
(
sh
<
shmin
)
shmin
=
sh
;
#if 0
if (sh > uh) {
printk("NOT SCHEDULABLE in head: %s\n", tsk->name);
BUG();
}
#endif
uh
=
uh
-
sh
;
}
/* slots after deadline of T0 */
st
=
h
*
tsk
->
attr
.
wcet
*
f1
/
tsk
->
attr
.
period
;
if
(
st
<
stmin
)
stmin
=
st
;
// printk("%s tail usage: %lld\n", tsk->name, ktime_to_ms(st));
#if 0
if (st > ut) {
printk("NOT SCHEDULABLE in tail: %s\n", tsk->name);
BUG();
}
#endif
ut
=
ut
-
st
;
printk
(
"w %s UH: %lld, UT: %lld
\n
"
,
tsk
->
name
,
ktime_to_us
(
uh
),
ktime_to_us
(
ut
));
printk
(
"w %s SH: %lld, ST: %lld
\n
"
,
tsk
->
name
,
ktime_to_us
(
sh
),
ktime_to_us
(
st
));
}
}
/* add all in wakeup */
struct
task_struct
*
tmp2
;
if
(
!
list_empty
(
&
tq
->
wake
))
{
...
...
@@ -740,6 +799,9 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
/* slots before deadline of T0 */
sh
=
h
*
tsk
->
attr
.
wcet
*
t0
->
attr
.
deadline_rel
/
tsk
->
attr
.
period
;
if
(
sh
<
shmin
)
shmin
=
sh
;
#if 0
if (sh > uh) {
printk("NOT SCHEDULABLE in head: %s\n", tsk->name);
...
...
@@ -752,6 +814,8 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
/* slots after deadline of T0 */
st
=
h
*
tsk
->
attr
.
wcet
*
f1
/
tsk
->
attr
.
period
;
if
(
st
<
stmin
)
stmin
=
st
;
// printk("%s tail usage: %lld\n", tsk->name, ktime_to_ms(st));
#if 0
...
...
@@ -785,6 +849,9 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
/* slots before deadline of T0 */
sh
=
h
*
tsk
->
attr
.
wcet
*
t0
->
attr
.
deadline_rel
/
tsk
->
attr
.
period
;
if
(
sh
<
shmin
)
shmin
=
sh
;
#if 0
if (sh > uh) {
printk("NOT SCHEDULABLE in head: %s\n", tsk->name);
...
...
@@ -797,6 +864,8 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
/* slots after deadline of T0 */
st
=
h
*
tsk
->
attr
.
wcet
*
f1
/
tsk
->
attr
.
period
;
if
(
st
<
stmin
)
stmin
=
st
;
// printk("%s tail usage: %lld\n", tsk->name, ktime_to_ms(st));
//
#if 0
...
...
@@ -813,21 +882,37 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
}
}
printk
(
"r SH: %lld, ST: %lld
\n
"
,
ktime_to_us
(
uh
/
h
),
ktime_to_us
(
ut
/
h
));
printk
(
"r SH: %lld
(%lld)
, ST: %lld
(%lld)
\n
"
,
ktime_to_us
(
uh
/
h
),
uh
,
ktime_to_us
(
ut
/
h
)
,
ut
);
if
(
ut
<
0
)
{
printk
(
"NOT SCHEDULABLE in tail: %s
\n
"
,
task
->
name
);
if
(
ut
<
=
0
)
{
printk
(
"NOT SCHEDULABLE in tail: %s
%lld
\n
"
,
task
->
name
,
ut
);
BUG
();
}
if
(
uh
<
0
)
{
printk
(
"NOT SCHEDULABLE in head: %s
\n
"
,
task
->
name
);
if
(
uh
<
=
0
)
{
printk
(
"NOT SCHEDULABLE in head: %s
%lld
\n
"
,
task
->
name
,
uh
);
BUG
();
}
static
int
cnt
;
if
(
cnt
)
{
#if 1
if
(
ut
<=
stmin
)
{
printk
(
"xx NOT SCHEDULABLE in tail: %s %lld vs %lld
\n
"
,
task
->
name
,
ut
,
stmin
);
// BUG();
}
#endif
#if 0
if (uh <= shmin) {
printk("xx NOT SCHEDULABLE in head: %s %lld vs %lld \n", task->name, uh, shmin);
// BUG();
}
#endif
}
cnt
++
;
...
...
@@ -968,7 +1053,7 @@ static struct task_struct *edf_pick_next(struct task_queue *tq)
first
=
list_first_entry
(
&
tq
->
run
,
struct
task_struct
,
node
);
if
(
ktime_before
(
tsk
->
wakeup
,
now
))
{
if
(
ktime_before
(
tsk
->
deadline
,
first
->
deadline
))
{
if
(
ktime_before
(
tsk
->
deadline
-
tsk
->
runtime
,
first
->
deadline
))
{
tsk
->
state
=
TASK_RUN
;
// go = tsk;
list_move
(
&
tsk
->
node
,
&
tq
->
run
);
...
...
@@ -993,7 +1078,8 @@ static struct task_struct *edf_pick_next(struct task_queue *tq)
first
=
list_first_entry
(
&
tq
->
run
,
struct
task_struct
,
node
);
if
(
ktime_before
(
tsk
->
deadline
,
first
->
deadline
))
{
//if (ktime_before (tsk->deadline, first->deadline)) {
if
(
ktime_before
(
tsk
->
deadline
-
tsk
->
runtime
,
first
->
deadline
))
{
// go = tsk;
list_move
(
&
tsk
->
node
,
&
tq
->
run
);
// printk("%s has earlier deadline, moved to top\n", tsk->name);
...
...
This diff is collapsed.
Click to expand it.
tools/testing/unittest/edf/edf_test.c
+
28
−
9
View file @
0ada692d
...
...
@@ -88,9 +88,9 @@ static void sched_edf_create_tasks_test(void)
t
->
sched
=
&
sched_edf
;
t
->
attr
.
policy
=
SCHED_EDF
;
t
->
attr
.
period
=
us_to_ktime
(
15
00
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
4
00
);
t
->
attr
.
wcet
=
us_to_ktime
(
300
);
t
->
attr
.
period
=
us_to_ktime
(
8
00
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
7
00
);
t
->
attr
.
wcet
=
us_to_ktime
(
89
);
edf_enqueue
(
&
t
->
sched
->
tq
,
t
);
...
...
@@ -105,9 +105,9 @@ static void sched_edf_create_tasks_test(void)
t
->
sched
=
&
sched_edf
;
t
->
attr
.
policy
=
SCHED_EDF
;
t
->
attr
.
period
=
us_to_ktime
(
3
0
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
2
0
);
t
->
attr
.
wcet
=
us_to_ktime
(
1
0
);
t
->
attr
.
period
=
us_to_ktime
(
3
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
2
);
t
->
attr
.
wcet
=
us_to_ktime
(
1
);
edf_enqueue
(
&
t
->
sched
->
tq
,
t
);
...
...
@@ -122,10 +122,29 @@ static void sched_edf_create_tasks_test(void)
t
->
sched
=
&
sched_edf
;
t
->
attr
.
policy
=
SCHED_EDF
;
t
->
attr
.
period
=
us_to_ktime
(
3
000
);
t
->
attr
.
period
=
us_to_ktime
(
2
000
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
900
);
t
->
attr
.
wcet
=
us_to_ktime
(
1
00
);
t
->
attr
.
wcet
=
us_to_ktime
(
1
25
);
edf_enqueue
(
&
t
->
sched
->
tq
,
t
);
/* create task 5 */
t
=
kmalloc
(
sizeof
(
struct
task_struct
));
KSFT_ASSERT_PTR_NOT_NULL
(
t
);
t
->
name
=
kmalloc
(
32
);
KSFT_ASSERT_PTR_NOT_NULL
(
t
->
name
);
snprintf
(
t
->
name
,
32
,
"task_5"
);
t
->
sched
=
&
sched_edf
;
t
->
attr
.
policy
=
SCHED_EDF
;
t
->
attr
.
period
=
us_to_ktime
(
1000
);
t
->
attr
.
deadline_rel
=
us_to_ktime
(
900
);
t
->
attr
.
wcet
=
us_to_ktime
(
99
);
edf_enqueue
(
&
t
->
sched
->
tq
,
t
);
}
...
...
@@ -133,7 +152,7 @@ static void sched_edf_create_tasks_test(void)
* @test sched_edf_create_tasks_test
*/
#define CYCLES
1
0000
#define CYCLES
2
0000
static
void
sched_edf_schedule_test
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment