feat(kernel): implement Phase 4 - preemptive multitasking, round-robin scheduler, PCB, x86_64 context switch & syscalls

This commit is contained in:
Adam Eehan committed 2026-10-23 17:36:52 +05:30
1 parent 7a584ea6e6
commit 6ee659ac6b
9 files changed
+444 -6

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
/*
* Airlys Operating System - x86_64 Context Switch
* Engineered by Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
* Co-Engineered with Sovereign AI Aira 3 Ultra (Engine v3.6)
*
* Prototype: void task_switch(uintptr_t* prev_rsp, uintptr_t* next_rsp);
* System V ABI: %rdi = prev_rsp, %rsi = next_rsp
*/
.section .text
.global task_switch
.type task_switch, @function
task_switch:
/* 1. Save RFLAGS and Callee-saved general purpose registers */
pushfq
pushq %rbx
pushq %rbp
pushq %r12
pushq %r13
pushq %r14
pushq %r15
/* 2. Store current stack pointer in outgoing task structure */
movq %rsp, (%rdi)
/* 3. Switch stack pointer to incoming task */
movq (%rsi), %rsp
/* 4. Restore Callee-saved registers of incoming task */
popq %r15
popq %r14
popq %r13
popq %r12
popq %rbp
popq %rbx
popfq
/* 5. Return jumps to incoming task's instruction pointer (RIP) */
ret