From db684b8653d93f4a374d8d692bb0afb31db67987 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Thu, 28 Mar 2024 22:00:16 -0500 Subject: kernel: add a basic thread scheduler Add a basic thread scheduler. This should allow the kernel to schedule threads according to the round robin algorithm. Signed-off-by: Danny Holman --- arch/i386/kernel/switch_thread.s | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 arch/i386/kernel/switch_thread.s (limited to 'arch/i386/kernel/switch_thread.s') diff --git a/arch/i386/kernel/switch_thread.s b/arch/i386/kernel/switch_thread.s new file mode 100644 index 0000000..f1168d5 --- /dev/null +++ b/arch/i386/kernel/switch_thread.s @@ -0,0 +1,28 @@ +.global switch_thread +.type switch_thread, @function +switch_thread: + pushl %ebp + movl %esp, %ebp + + pushl %ebx + pushl %esi + pushl %edi + pushl %ebp + + movl 8(%ebp), %esi + movl 12(%ebp), %edi + + movl %esp, (%edi); + movl %cr3, %ecx + movl %ecx, 4(%edi) + + movl (%esi), %esp + movl 4(%esi), %ecx + movl %ecx, %cr3 + + popl %ebp + popl %edi + popl %esi + popl %ebx + popl %ebp + ret -- cgit v1.2.3