[MULTITASKING] Context switching and scheduler

This commit is contained in:
2016-11-05 19:55:54 +01:00
parent 1f06c0bcf1
commit 5e8fbcbb78
9 changed files with 288 additions and 0 deletions

View File

@@ -3,6 +3,16 @@
#include <multiboot.h>
#include <mem.h>
#include <gdt.h>
#include <scheduler.h>
void thread_function()
{
while(1)
{
debug("%d", get_current_thread()->tid);
schedule();
}
}
int kmain(uint64_t multiboot_magic, void *multiboot_data)
{
@@ -16,8 +26,17 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
vmm_init();
pmm_init();
gdt_init();
scheduler_init();
scheduler_insert(new_thread(thread_function));
scheduler_insert(new_thread(thread_function));
scheduler_insert(new_thread(thread_function));
scheduler_insert(new_thread(thread_function));
scheduler_insert(new_thread(thread_function));
debug_info("BOOT COMPLETE\n");
schedule();
debug_error("PANIC - This line should be unreachable (%s:%d)\n", __FILE__, __LINE__);
for(;;)asm("hlt");
}