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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
FlightOS
Commits
a43ee518
Commit
a43ee518
authored
5 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
saving working state of EDF + core scheduler in actual OS
parent
88c53c0a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
init/main.c
+6
-4
6 additions, 4 deletions
init/main.c
kernel/sched/core.c
+23
-16
23 additions, 16 deletions
kernel/sched/core.c
kernel/sched/edf.c
+4
-2
4 additions, 2 deletions
kernel/sched/edf.c
with
33 additions
and
22 deletions
init/main.c
+
6
−
4
View file @
a43ee518
...
@@ -251,7 +251,7 @@ int kernel_main(void)
...
@@ -251,7 +251,7 @@ int kernel_main(void)
attr
.
wcet
=
us_to_ktime
(
200
);
attr
.
wcet
=
us_to_ktime
(
200
);
sched_set_attr
(
t
,
&
attr
);
sched_set_attr
(
t
,
&
attr
);
kthread_wake_up
(
t
);
kthread_wake_up
(
t
);
#if 1
t
=
kthread_create
(
task3
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"print2"
);
t
=
kthread_create
(
task3
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"print2"
);
sched_get_attr
(
t
,
&
attr
);
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
policy
=
SCHED_EDF
;
...
@@ -260,7 +260,8 @@ int kernel_main(void)
...
@@ -260,7 +260,8 @@ int kernel_main(void)
attr
.
wcet
=
us_to_ktime
(
100
);
attr
.
wcet
=
us_to_ktime
(
100
);
sched_set_attr
(
t
,
&
attr
);
sched_set_attr
(
t
,
&
attr
);
kthread_wake_up
(
t
);
kthread_wake_up
(
t
);
#endif
#if 1
t
=
kthread_create
(
task1
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"print3"
);
t
=
kthread_create
(
task1
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"print3"
);
sched_get_attr
(
t
,
&
attr
);
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
policy
=
SCHED_EDF
;
...
@@ -269,7 +270,8 @@ int kernel_main(void)
...
@@ -269,7 +270,8 @@ int kernel_main(void)
attr
.
wcet
=
us_to_ktime
(
100
);
attr
.
wcet
=
us_to_ktime
(
100
);
sched_set_attr
(
t
,
&
attr
);
sched_set_attr
(
t
,
&
attr
);
kthread_wake_up
(
t
);
kthread_wake_up
(
t
);
#endif
#if 1
t
=
kthread_create
(
task0
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"res"
);
t
=
kthread_create
(
task0
,
NULL
,
KTHREAD_CPU_AFFINITY_NONE
,
"res"
);
sched_get_attr
(
t
,
&
attr
);
sched_get_attr
(
t
,
&
attr
);
attr
.
policy
=
SCHED_EDF
;
attr
.
policy
=
SCHED_EDF
;
...
@@ -278,7 +280,7 @@ int kernel_main(void)
...
@@ -278,7 +280,7 @@ int kernel_main(void)
attr
.
wcet
=
ms_to_ktime
(
100
);
attr
.
wcet
=
ms_to_ktime
(
100
);
sched_set_attr
(
t
,
&
attr
);
sched_set_attr
(
t
,
&
attr
);
kthread_wake_up
(
t
);
kthread_wake_up
(
t
);
#endif
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
kernel/sched/core.c
+
23
−
16
View file @
a43ee518
...
@@ -36,7 +36,9 @@ void schedule(void)
...
@@ -36,7 +36,9 @@ void schedule(void)
struct
task_struct
*
current
;
struct
task_struct
*
current
;
int64_t
slot_ns
;
int64_t
slot_ns
;
int64_t
wake_ns
=
0
;
int64_t
wake_ns
=
1000000000
;
ktime
rt
;
static
int
once
;
static
int
once
;
...
@@ -55,12 +57,20 @@ void schedule(void)
...
@@ -55,12 +57,20 @@ void schedule(void)
/* get the current task for this CPU */
/* get the current task for this CPU */
current
=
current_set
[
0
]
->
task
;
current
=
current_set
[
0
]
->
task
;
rt
=
ktime_sub
(
ktime_get
(),
current
->
exec_start
);
/** XXX need timeslice_update callback for schedulers */
/** XXX need timeslice_update callback for schedulers */
/* update remaining runtime of current thread */
/* update remaining runtime of current thread */
current
->
runtime
=
ktime_sub
(
current
->
exec_start
,
ktime_get
());
current
->
runtime
=
ktime_sub
(
current
->
runtime
,
rt
);
current
->
total
=
ktime_add
(
current
->
total
,
rt
);
retry:
retry:
next
=
NULL
;
wake_ns
=
1000000000
;
/* XXX: for now, try to wake up any threads not running
/* XXX: for now, try to wake up any threads not running
* this is a waste of cycles and instruction space; should be
* this is a waste of cycles and instruction space; should be
* done in the scheduler's code (somewhere) */
* done in the scheduler's code (somewhere) */
...
@@ -82,13 +92,15 @@ retry:
...
@@ -82,13 +92,15 @@ retry:
* next is non-NULL
* next is non-NULL
*/
*/
next
=
sched
->
pick_next_task
(
&
sched
->
tq
);
next
=
sched
->
pick_next_task
(
&
sched
->
tq
);
#if 0
#if 0
if (next)
if (next)
printk("next %s %llu %llu\n", next->name, next->first_wake, ktime_get());
printk("next %s %llu %llu\n", next->name, next->first_wake, ktime_get());
else
else
printk("NULL
\n"
);
printk("NULL
%llu\n", ktime_get()
);
#endif
#endif
/* check if we need to limit the next tasks timeslice;
/* check if we need to limit the next tasks timeslice;
* since our scheduler list is sorted by scheduler priority,
* since our scheduler list is sorted by scheduler priority,
* only update the value if wake_next is not set;
* only update the value if wake_next is not set;
...
@@ -109,22 +121,17 @@ retry:
...
@@ -109,22 +121,17 @@ retry:
* the corresponding scheduler
* the corresponding scheduler
*/
*/
if
(
!
wake_ns
)
if
(
next
)
{
wake_ns
=
sched
->
task_ready_ns
(
&
sched
->
tq
);
slot_ns
=
next
->
sched
->
timeslice_ns
(
next
);
/* we found something to execute, off we go */
/* we found something to execute, off we go */
if
(
next
)
break
;
break
;
}
}
}
if
(
!
next
)
{
if
(
!
next
)
{
/* there is absolutely nothing nothing to do, check again later */
/* there is absolutely nothing nothing to do, check again later */
if
(
wake_ns
)
tick_set_next_ns
(
wake_ns
);
tick_set_next_ns
(
wake_ns
);
else
tick_set_next_ns
(
1e9
);
/* XXX pause for a second, there are no threads in any scheduler */
goto
exit
;
goto
exit
;
}
}
...
@@ -134,7 +141,7 @@ retry:
...
@@ -134,7 +141,7 @@ retry:
* schedulers, e.g. EDF
* schedulers, e.g. EDF
*/
*/
slot
_ns
=
next
->
sched
->
t
imeslice_ns
(
next
);
wake
_ns
=
sched
->
t
ask_ready_ns
(
&
sched
->
tq
);
if
(
wake_ns
<
slot_ns
)
if
(
wake_ns
<
slot_ns
)
slot_ns
=
wake_ns
;
slot_ns
=
wake_ns
;
...
@@ -152,9 +159,9 @@ retry:
...
@@ -152,9 +159,9 @@ retry:
/* subtract readout overhead */
/* subtract readout overhead */
tick_set_next_ns
(
ktime_sub
(
slot_ns
,
2000LL
));
tick_set_next_ns
(
ktime_sub
(
slot_ns
,
2000LL
));
#if 1
#if 1
if
(
slot_ns
<
20000UL
)
{
if
(
slot_ns
<
19000UL
)
{
// printk("wake %llu slot %llu %s\n", wake_ns, slot_ns, next->name);
goto
retry
;
goto
retry
;
printk
(
"wake %llu slot %llu %s
\n
"
,
wake_ns
,
slot_ns
,
next
->
name
);
BUG
();
BUG
();
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
kernel/sched/edf.c
+
4
−
2
View file @
a43ee518
...
@@ -107,6 +107,7 @@ static inline bool schedule_edf_can_execute(struct task_struct *tsk, ktime now)
...
@@ -107,6 +107,7 @@ static inline bool schedule_edf_can_execute(struct task_struct *tsk, ktime now)
if
(
tsk
->
runtime
<=
0
)
if
(
tsk
->
runtime
<=
0
)
return
false
;
return
false
;
if
(
ktime_before
(
tsk
->
deadline
,
now
))
{
if
(
ktime_before
(
tsk
->
deadline
,
now
))
{
sched_print_edf_list_internal
(
&
tsk
->
sched
->
tq
,
ktime_get
());
printk
(
"%s violated, %lld %lld, dead %lld wake %lld now %lld start %lld
\n
"
,
tsk
->
name
,
printk
(
"%s violated, %lld %lld, dead %lld wake %lld now %lld start %lld
\n
"
,
tsk
->
name
,
tsk
->
runtime
,
ktime_us_delta
(
tsk
->
deadline
,
now
),
tsk
->
runtime
,
ktime_us_delta
(
tsk
->
deadline
,
now
),
tsk
->
deadline
,
tsk
->
wakeup
,
now
,
tsk
->
exec_start
);
tsk
->
deadline
,
tsk
->
wakeup
,
now
,
tsk
->
exec_start
);
...
@@ -153,6 +154,8 @@ static inline void schedule_edf_reinit_task(struct task_struct *tsk, ktime now)
...
@@ -153,6 +154,8 @@ static inline void schedule_edf_reinit_task(struct task_struct *tsk, ktime now)
tsk
->
deadline
=
ktime_add
(
tsk
->
wakeup
,
tsk
->
attr
.
deadline_rel
);
tsk
->
deadline
=
ktime_add
(
tsk
->
wakeup
,
tsk
->
attr
.
deadline_rel
);
tsk
->
runtime
=
tsk
->
attr
.
wcet
;
tsk
->
runtime
=
tsk
->
attr
.
wcet
;
tsk
->
slices
++
;
}
}
...
@@ -242,7 +245,6 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
...
@@ -242,7 +245,6 @@ static int edf_schedulable(struct task_queue *tq, const struct task_struct *task
return
0
;
return
0
;
}
}
u
=
(
double
)
(
int32_t
)
task
->
attr
.
wcet
/
(
double
)
(
int32_t
)
task
->
attr
.
period
;
return
0
;
return
0
;
}
}
...
@@ -346,7 +348,7 @@ static struct task_struct *edf_pick_next(struct task_queue *tq)
...
@@ -346,7 +348,7 @@ static struct task_struct *edf_pick_next(struct task_queue *tq)
slot
=
first
->
runtime
;
slot
=
first
->
runtime
;
}
}
#if
0
/* XXX should not be needed, but needs verification! */
#if
1
/* XXX should not be needed, but needs verification! */
if
(
!
go
)
{
if
(
!
go
)
{
list_for_each_entry_safe
(
tsk
,
tmp
,
&
tq
->
run
,
node
)
{
list_for_each_entry_safe
(
tsk
,
tmp
,
&
tq
->
run
,
node
)
{
...
...
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