Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 252b567)
raw | patch | inline | side by side (parent: 252b567)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Mon, 1 Nov 2021 08:10:46 +0000 (16:10 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Wed, 3 Nov 2021 02:45:45 +0000 (10:45 +0800) |
| kernel/init.c | patch | blob | history | |
| kernel/sched.c | patch | blob | history |
diff --git a/kernel/init.c b/kernel/init.c
--- a/kernel/init.c
+++ b/kernel/init.c
void root_task_entry()
{
- //kernel_task(init_task_entry);
+ kernel_task(init_task_entry);
//kernel_task(user_task_entry);
//kernel_task(init_task_entry);
diff --git a/kernel/sched.c b/kernel/sched.c
--- a/kernel/sched.c
+++ b/kernel/sched.c
irq_save(iflags);
printl(MPL_ROOT, "root:%d [%08x] cnt %u", root_task.pid, &root_task, root_task.cnt);
- unsigned int min_ratio = ~0U;
+ float min_ratio = 1.0;
+
+ bool need_reset_weight = true;
+ list_for_each_safe(pos, t, &all_tasks)
+ {
+ p = list_entry(pos, task_union, list);
+ if (p->state != TASK_RUNNING)
+ {
+ continue;
+ }
+ if (p->weight < p->priority)
+ {
+ need_reset_weight = false;
+ break;
+ }
+ }
+
+ if (need_reset_weight)
+ {
+ list_for_each_safe(pos, t, &all_tasks)
+ {
+ p = list_entry(pos, task_union, list);
+ if (p->state != TASK_RUNNING)
+ {
+ continue;
+ }
+ p->weight = 0;
+ }
+ }
list_for_each_safe(pos, t, &all_tasks)
{
continue;
}
- printd("%08x %s weight %d\n", p, p->name, p->weight);
+ //printd("%08x %s weight %d\n", p, p->name, p->weight);
- unsigned int ratio = p->weight / p->priority;
+ float ratio = (float)(p->weight * 1.0) / (p->priority * 1.0);
if (ratio < min_ratio)
{
sel = p;
min_ratio = ratio;
}
-
- p->weight++;
- if (p->weight > p->priority)
- {
- p->weight = 0;
- }
}
irq_restore(iflags);
- sel = &root_task;
+ sel->weight++;
+ printd("%08x %s weight %d\n", sel, sel->name, sel->weight);
task_union *prev = current;
task_union *next = sel;