From 17ae4cf63047a568babcd0a86abd87a857254c21 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Mon, 8 Nov 2021 01:33:50 +0800 Subject: [PATCH] kernel: add a test function for smp thread --- kernel/kmain.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/kmain.c b/kernel/kmain.c index ec9acfa..678119d 100644 --- a/kernel/kmain.c +++ b/kernel/kmain.c @@ -35,6 +35,14 @@ static inline int minmax(int val, int min, int max) { return val; } +static SYSV_ABI void kThreader(int a, int b, int c, int d, int e, int f) { + io_Printf("kThreader: args[%d,%d,%d,%d,%d,%d]\n", a, b, c, d, e, f); + for (;;) { + smp_thread_Sleep(768); + io_Printf("kThreader: Not sleeping!\n"); + } +} + SYSV_ABI void kMain() { io_WriteConsoleASCII("Yes! kMain survived!\n"); @@ -73,7 +81,12 @@ SYSV_ABI void kMain() { io_WriteConsoleASCII("kMain: Initializing threading\n"); smp_thread_ID tid = smp_thread_Init(); - io_WriteConsoleASCII("kMain: Threading OK\n"); + io_Printf("kMain: Threading OK, id=%d\n", tid); + + smp_thread_Arguments args = {1, 2, 3, 4, 5, 6}; + + tid = smp_thread_Start(kThreader, &args, SMP_NICENESS_DEFAULT); + io_Printf("New thread, id=%d\n", tid); for (;;) { //asm volatile("hlt");