From: acevest Date: Fri, 5 Nov 2021 07:03:35 +0000 (+0800) Subject: print sched cnt X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.html?a=commitdiff_plain;h=5ef7b1a77656397631bebf8ef599215fbe4ee103;p=kernel.git print sched cnt --- diff --git a/include/task.h b/include/task.h index ad950a9..38f9250 100644 --- a/include/task.h +++ b/include/task.h @@ -67,6 +67,8 @@ typedef union task_union { wait_queue_head_t wait; + unsigned int sched_cnt; + unsigned int cnt; // debug only }; diff --git a/kernel/init.c b/kernel/init.c index 8b36e12..7774e71 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -61,6 +61,8 @@ void __ring3text__ __attribute__((__aligned__(PAGE_SIZE))) ring3_entry() { void user_task_entry(char *name) { strcpy(current->name, name); + current->priority = 90; + unsigned long ring3_text_page = va2pa(ring3_entry); unsigned long ring3_bss_page = va2pa(alloc_one_page(0)); @@ -99,6 +101,7 @@ void init_task_entry(char *name) { // 赋予不同的优先级 current->priority = id * 30; + if (current->priority <= 0) { current->priority = 1; } @@ -150,6 +153,7 @@ void root_task_entry() { kernel_task("user", user_task_entry); int cnt = 0; + while (1) { // sysc_test(); // printl(MPL_TASK_0, "root:0 [%08x] weight %d cnt %d", current, root_task.weight, cnt++); diff --git a/kernel/sched.c b/kernel/sched.c index d458525..fd0bb48 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -194,11 +194,11 @@ unsigned long schedule() { if (prev != next) { // printk("switch to: %s:%d\n", next->name, next->pid); - + sel->sched_cnt++; list_for_each_safe(pos, t, &all_tasks) { p = list_entry(pos, task_union, list); - printl(MPL_TASK_0 + p->pid, "%s%4s:%d [%08x] state %s weight %03d cnt %u", sel == p ? ">" : " ", p->name, - p->pid, p, task_state(p->state), p->weight, p->cnt); + printl(MPL_TASK_0 + p->pid, "%s%4s:%d [%08x] state %s weight %03d sched %u", sel == p ? ">" : " ", p->name, + p->pid, p, task_state(p->state), p->weight, p->sched_cnt); } context_switch(prev, next); }