Skip to content
Snippets Groups Projects
Commit f6547b18 authored by Armin Luntzer's avatar Armin Luntzer
Browse files

EDF scheulability analysis:

	* saving changes
parent d0d927b5
Branches
No related tags found
No related merge requests found
......@@ -13,6 +13,16 @@
#include <kernel/time.h>
struct remove_this_declaration {
struct list_head new;
struct list_head run;
struct list_head wake;
struct list_head dead;
};
#define KTHREAD_CPU_AFFINITY_NONE (-1)
......
......@@ -49,7 +49,7 @@
int task1(void *data)
{
while (1) {
printk(".");
// printk(".");
// sched_yield();
}
}
......@@ -58,7 +58,7 @@ int task1(void *data)
int task2(void *data)
{
while (1) {
printk("-");
// printk("-");
// sched_yield();
}
}
......@@ -151,23 +151,50 @@ int kernel_main(void)
/* elevate boot thread */
kernel = kthread_init_main();
/*
* T1: (P=50, D=20, R=10)
*
* T2: (P= 4, D= 2, R= 1)
* T5: (P=20, D=12, R= 5)
*
* T6: (P=33, D=30, R= 4)
* T7: (P=50, D=46, R= 6)
*/
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "T1");
kthread_set_sched_edf(t, 50 * MSEC_PER_SEC, 10 * MSEC_PER_SEC, 20 * MSEC_PER_SEC);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "T2");
kthread_set_sched_edf(t, 4 * MSEC_PER_SEC, 1 * MSEC_PER_SEC, 2 * MSEC_PER_SEC);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "T5");
kthread_set_sched_edf(t, 20 * MSEC_PER_SEC, 5 * MSEC_PER_SEC, 12 * MSEC_PER_SEC);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "T6");
kthread_set_sched_edf(t, 33 * MSEC_PER_SEC, 4 * MSEC_PER_SEC, 30 * MSEC_PER_SEC);
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "T7");
kthread_set_sched_edf(t, 50 * MSEC_PER_SEC, 6 * MSEC_PER_SEC, 46 * MSEC_PER_SEC);
#if 0
t = kthread_create(task1, NULL, KTHREAD_CPU_AFFINITY_NONE, "print");
//kthread_set_sched_edf(t, 1000000, 50000, 90000);
t->priority = 4;
kthread_wake_up(t);
t = kthread_create(task2, NULL, KTHREAD_CPU_AFFINITY_NONE, "print1");
//kthread_set_sched_edf(t, 1000000, 50000, 90000);
t->priority = 8;
kthread_wake_up(t);
#endif
while(1) {
printk("|");
//printk("|");
cpu_relax();
}
......
obj-y += sched/
obj-y += kmem.o
obj-y += ksym.o
obj-$(CONFIG_KERNEL_PRINTK) += printk.o
......
......@@ -24,12 +24,12 @@
#define MSG "KTHREAD: "
static struct {
struct remove_this_declaration /*{
struct list_head new;
struct list_head run;
struct list_head wake;
struct list_head dead;
} _kthreads = {
}*/ _kthreads = {
.new = LIST_HEAD_INIT(_kthreads.new),
.run = LIST_HEAD_INIT(_kthreads.run),
.wake = LIST_HEAD_INIT(_kthreads.wake),
......@@ -133,6 +133,9 @@ void sched_wake(struct task_struct *next, ktime now, int64_t slot_ns)
#define OVERHEAD 0LL
/* XXX */
int64_t schedule_edf(ktime now);
void schedule(void)
{
struct task_struct *next;
......@@ -203,7 +206,7 @@ void schedule(void)
#if 0
#if 1
slot_ns = schedule_edf(now);
#endif
......@@ -261,7 +264,7 @@ void schedule(void)
}
__attribute__((unused))
static void kthread_set_sched_policy(struct task_struct *task,
/* static */ void kthread_set_sched_policy(struct task_struct *task,
enum sched_policy policy)
{
arch_local_irq_disable();
......
......@@ -20,6 +20,11 @@
#include <kernel/tick.h>
extern struct remove_this_declaration _kthreads;
void kthread_set_sched_policy(struct task_struct *task,
enum sched_policy policy);
void sched_print_edf_list_internal(ktime now)
{
......@@ -65,7 +70,8 @@ void sched_print_edf_list_internal(ktime now)
prevd = tsk->deadline;
}
}
ktime total;
ktime times;
void sched_print_edf_list(void)
{
printk("avg: %lld\n", ktime_to_us(total/times));
......@@ -161,7 +167,7 @@ static inline void schedule_edf_reinit_task(struct task_struct *tsk, ktime now)
#define SOME_DEFAULT_TICK_PERIOD_FOR_SCHED_MODE 10000000LL
/* stupidly sort EDFs */
static int64_t schedule_edf(ktime now)
/*static*/ int64_t schedule_edf(ktime now)
{
// ktime now;
......@@ -249,11 +255,13 @@ static int64_t schedule_edf(ktime now)
BUG_ON(slot <= 0);
}
}
#if 1
total = ktime_add(total, ktime_delta(ktime_get(), now));
times++;
//printk("%3.d %3.lld\n", cnt, ktime_to_us(total / times) );
#endif
#if 0
printk("%3.d %3.lld\n", cnt, ktime_to_us(total / times) );
#endif
BUG_ON(slot < 0);
return slot;
......@@ -577,7 +585,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
task->deadline_rel = us_to_ktime(deadline_rel_us);
arch_local_irq_enable();
printk("\nvvvv EDF analysis vvvv\n\n");
{
ktime p = hyperperiod();
ktime h ;
......@@ -605,7 +613,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
BUG_ON(p < t0->period);
h = p / t0->period;
// printk("Period factor %lld %lld %lld\n", h, p, t0->period);
printk("Period factor %lld, duration %lld actual min period: %lld\n", h, ktime_to_ms(p), ktime_to_ms(t0->period));
......@@ -614,7 +622,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
f1 = ut/h;
printk("max UH: %lld, UT: %lld\n", (uh), (ut));
printk("max UH: %lld, UT: %lld\n", ktime_to_ms(uh), ktime_to_ms(ut));
list_for_each_entry_safe(tsk, tmp, &_kthreads.new, node) {
......@@ -647,7 +655,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
ut = ut - st;
printk("UH: %lld, UT: %lld\n", (uh),(ut));
printk("UH: %lld, UT: %lld\n", ktime_to_ms(uh), ktime_to_ms(ut));
}
......@@ -692,6 +700,7 @@ void kthread_set_sched_edf(struct task_struct *task, unsigned long period_us,
}
}
printk("\n^^^^ EDF analysis ^^^^\n");
// arch_local_irq_enable();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment