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

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

View file

@ -239,7 +239,10 @@ void interrupt_handler(interrupt_frame *r){
if(r->int_no == 69 && get_cpu_struct_initialized()
&& get_cpu_struct()->scheduler_initialized){
enter_scheduler();
if(get_cpu_struct()->current_process->state == RUNNING){
enter_scheduler();
}
}
if(r->int_no == 70){

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,20 +16,15 @@ int next_pid = 1;
void idle_task(){
for(;;){
kprintf("Idle!!1\n");
}
}
void test_task(){
for(;;){
kprintf("Hello world from scheduled task!\n");
}
kprintf("Hello world from scheduled task!\n");
}
void best_task(){
for(;;){
kprintf("Hello world I am best\n");
}
kprintf("Hello world I am best\n");
}
/* Setup a process structure */
@ -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 {