Working on scheduling

This commit is contained in:
ssimnb 2026-02-02 17:42:52 +01:00
parent cfcb806ebf
commit edfbfdad14
9 changed files with 19 additions and 39 deletions

View file

@ -20,8 +20,7 @@ CFLAGS += -Wall \
-I src/include \
-O0 \
-ggdb3 \
-g \
#-fno-omit-frame-pointer
-g
CDEBUG = -g
LDFLAGS += -m elf_x86_64 \
-nostdlib \
@ -95,9 +94,9 @@ all:
-no-emul-boot -boot-load-size 4 -boot-info-table \
--efi-boot limine-uefi-cd.bin \
-efi-boot-part --efi-boot-image --protective-msdos-label \
iso_root -o $(BUILD_DIR)/SFB25.iso
iso_root -o $(BUILD_DIR)/Neobbo.iso
# Install Limine stage 1 and 2 for legacy BIOS boot.
./limine/limine bios-install $(BUILD_DIR)/SFB25.iso
./limine/limine bios-install $(BUILD_DIR)/Neobbo.iso
disk:
dd if=/dev/zero of=disk.img bs=1M count=128
elftest:

View file

@ -12,7 +12,7 @@ qemu-system-x86_64 -s -S "$@" &
sleep 1
"$termname" -e gdb -ex 'target remote localhost:1234' -ex 'break _start' -ex 'continue' build/SFB25.elf
"$termname" -e gdb -ex 'target remote localhost:1234' -ex 'break _start' build/Neobbo.elf

View file

@ -7,7 +7,7 @@ timeout: 0
protocol: limine
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
kernel_path: boot():/SFB25.elf
kernel_path: boot():/Neobbo.elf
# Same thing, but without KASLR.
/Neobbo (KASLR off)
@ -17,4 +17,4 @@ timeout: 0
kaslr: no
# Path to the kernel to boot. boot:/// represents the partition on which limine.cfg is located.
kernel_path: boot():/SFB25.elf
kernel_path: boot():/Neobbo.elf

@ -1 +1 @@
Subproject commit 55d228ff16234513b0df0dd12de8bc58160fc196
Subproject commit cc71c677566453be4d1e821ede227a101868638c

View file

@ -239,9 +239,12 @@ void interrupt_handler(interrupt_frame *r){
if(r->int_no == 69 && get_cpu_struct_initialized()
&& get_cpu_struct()->scheduler_initialized){
if(get_cpu_struct()->current_process->state == RUNNING){
enter_scheduler();
}
}
if(r->int_no == 70){
for(;;){
asm("cli;hlt");

View file

@ -75,7 +75,7 @@ void _start(void){
NULL, NULL,
NULL, 0, 0, 1,
0, 0,
0
0, 0
);
kprintf("Welcome to Neobbo{n}");

View file

@ -3,19 +3,11 @@ global switch_context
global get_context
global restore_stack
; switch_context(struct context **old, *struct context new)
; switch_context(struct context **old, struct context *new)
; ^RDI ^RSI
switch_context:
push rdi
push rsi
push rdx
push rcx
push rbx
push rbp
push r8
push r9
push r10
push r11
push r12
push r13
push r14
@ -28,15 +20,7 @@ switch_context:
pop r14
pop r13
pop r12
pop r11
pop r10
pop r9
pop r8
pop rbp
pop rbx
pop rcx
pop rdx
pop rsi
pop rdi
ret

View file

@ -16,21 +16,16 @@ int next_pid = 1;
void idle_task(){
for(;;){
kprintf("Idle!!1\n");
}
}
void test_task(){
for(;;){
kprintf("Hello world from scheduled task!\n");
}
}
void best_task(){
for(;;){
kprintf("Hello world I am best\n");
}
}
/* Setup a process structure */
proc *alloc_process(void){
@ -115,19 +110,18 @@ void scheduler_init(){
for(;;){
for(; i < PROC_MAX; i++){
if(proc_list[i].state == READY){
asm("sti");
proc *prev = state->current_process;
prev->state = READY;
state->current_process = &proc_list[i];
state->current_process->state = RUNNING;
switch_context(&(get_cpu_struct()->scheduler_context), get_cpu_struct()->current_process->context);
}
}
i = 1;
i = 0;
}
}
void enter_scheduler(){
switch_context(&get_cpu_struct()->current_process->context, (get_cpu_struct()->scheduler_context));
switch_context(&get_cpu_struct()->current_process->context, get_cpu_struct()->scheduler_context);
}

View file

@ -10,7 +10,7 @@ typedef enum proc_state {
}proc_state;
typedef struct context {
uint64_t r15, r14, r13, r12, r11, r10, r9, r8, rbp, rbx, rcx, rdx, rsi, rdi, rip;
uint64_t r15, r14, r13, r12, rbp, rbx, rip;
} context;
typedef struct proc {