]> Zhao Yanbai Git Server - kernel.git/commitdiff
print sched cnt
authoracevest <zhaoyanbai@126.com>
Fri, 5 Nov 2021 07:03:35 +0000 (15:03 +0800)
committeracevest <zhaoyanbai@126.com>
Fri, 5 Nov 2021 07:03:35 +0000 (15:03 +0800)
include/task.h
kernel/init.c
kernel/sched.c

index ad950a94a10e582f53d6811fdef7faffe346e217..38f9250c921f38de7bb59588506015b9ae14bce5 100644 (file)
@@ -67,6 +67,8 @@ typedef union task_union {
 
         wait_queue_head_t wait;
 
+        unsigned int sched_cnt;
+
         unsigned int cnt;  // debug only
     };
 
index 8b36e128876647860b32dda63c9a011ab1099f3b..7774e71ca49e1972bdbc77193120e59e5e9e9bd8 100644 (file)
@@ -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++);
index d458525c05d576d67b9e08ba2f6cdc42c978ecef..fd0bb48da93a0aa6e4ec3259370ab9f2c9a0729c 100644 (file)
@@ -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);
     }