apic ipis, scheduler stub, crappy and slow tlb shootdown

This commit is contained in:
Matheus
2022-08-09 23:53:39 -03:00
parent b2d8e5a166
commit c565bc006f
19 changed files with 242 additions and 54 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
objects := $(patsubst %.c,%.o,$(wildcard *.c))
subdirs := mm
subdirs := mm sched
OBJPATH=$(OBJDIR)
export
+12
View File
@@ -0,0 +1,12 @@
objects := $(patsubst %.c,%.o,$(wildcard *.c))
subdirs :=
OBJPATH=$(OBJDIR)
export
all: $(subdirs) $(objects)
for subdir in $(subdirs) ; do $(MAKE) -C $${subdir} ; done
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
mkdir -p $(OBJPATH)
cp $@ $(OBJPATH)/$@
+49
View File
@@ -0,0 +1,49 @@
#include <kernel/sched.h>
#include <arch/cls.h>
thread_t* queue;
thread_t* blocked;
static thread_t* next_thread(){
thread_t* thread = queue;
while(1){
while(thread != NULL && thread->state != THREAD_STATE_WAITING)
thread = thread->next;
if(!thread)
asm("hlt"); // wait until something happens that would allow a thread to be scheduled
}
return thread;
}
__attribute__((noreturn)) static void sched_switch(thread_t* thread){
thread_t* current = arch_getcls()->thread;
if(current->proc != thread->proc){
// change address spaces and all
}
arch_switchcontext(thread->regs);
__builtin_unreachable();
}
__attribute__((noreturn)) void sched_timerhook(arch_regs* c){
thread_t* current = arch_getcls()->thread;
memcpy(current->regs, c, sizeof(arch_regs));
;
__builtin_unreachable();
}