From 8497962af6ae3f3ccbce5695d9c969a3caea6dec Mon Sep 17 00:00:00 2001 From: Max Wash Date: Tue, 17 Sep 2024 17:49:34 +0100 Subject: [PATCH] kernel: show current task id, thread id, and cpu id in test messages --- init/main.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/init/main.c b/init/main.c index 2330dfb..0b1a904 100644 --- a/init/main.c +++ b/init/main.c @@ -15,10 +15,6 @@ #include #include -#ifdef KEXT_NET_DOORSTUCK_SOCKS_FBCON -#include -#endif - extern unsigned long get_rflags(void); extern char __pstart[], __pend[]; @@ -30,19 +26,30 @@ void print_kernel_banner(void) static void hang(void) { + struct task *self = current_task(); + struct thread *thread = current_thread(); + while (1) { - printk("%d: tick", this_cpu()); + printk("[cpu %u, task %u, thread %u]: tick", + this_cpu(), + self->t_id, + thread->tr_id); milli_sleep(2000); } } void background_thread(void) { + struct task *self = current_task(); + struct thread *thread = current_thread(); printk("background_thread() running on processor %u", this_cpu()); milli_sleep(1000); while (1) { - printk("%d: tock", this_cpu()); + printk("[cpu %u, task %u, thread %u]: tock", + this_cpu(), + self->t_id, + thread->tr_id); milli_sleep(2000); } }