summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-03-28 22:00:16 -0500
committerDanny Holman <dholman@gymli.org>2024-03-28 22:00:16 -0500
commitdb684b8653d93f4a374d8d692bb0afb31db67987 (patch)
tree83dc7939470b4c9302538fbf220c7a02fc249a51 /arch
parent3b66779d9a8325c77c6cfbf1565885f98da5378f (diff)
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 <dholman@gymli.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/switch_thread.s28
-rw-r--r--arch/i386/make.config2
2 files changed, 30 insertions, 0 deletions
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
diff --git a/arch/i386/make.config b/arch/i386/make.config
index 8499f1a..d4d98a7 100644
--- a/arch/i386/make.config
+++ b/arch/i386/make.config
@@ -17,3 +17,5 @@ KERNEL_ARCH_OBJS=$(ARCHDIR)/boot/boot.o \
$(ARCHDIR)/kernel/paging.o \
$(ARCHDIR)/kernel/pmem.o \
$(ARCHDIR)/kernel/kmalloc.o \
+ $(ARCHDIR)/kernel/jump_userspace.o \
+ $(ARCHDIR)/kernel/switch_thread.o \