[MULTITASKING] Processes

This commit is contained in:
thomas committed 2017-03-27 23:09:08 +02:00
1 parent 5e8fbcbb78
commit 5ca2b6994a
8 files changed
+177 -8

No files matched your search

+24 -6
View File
@@ -4,12 +4,19 @@
#include <mem.h>
#include <gdt.h>
#include <scheduler.h>
#include <thread.h>
#include <process.h>
void thread_function()
{
char *str = (char *)0x10000;
str[0] = (char)((unsigned int)'0' + get_current_process()->pid);
str[1] = (char)((unsigned int)'0' + get_current_thread()->tid);
str[3] = '-';
str[2] = '\0';
while(1)
{
debug("%d", get_current_thread()->tid);
debug((char *)0x10000);
schedule();
}
}
@@ -28,12 +35,23 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
gdt_init();
scheduler_init();
process_t *p1 = process_spawn(0);
process_t *p2 = process_spawn(p1);
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));
thread_t *t1 = new_thread(thread_function);
thread_t *t2 = new_thread(thread_function);
thread_t *t3 = new_thread(thread_function);
process_attach(p1, t1);
process_attach(p2, t2);
process_attach(p1, t3);
vmm_set_page(p1->P4, 0x10000, pmm_alloc(), PAGE_PRESENT | PAGE_WRITE);
vmm_set_page(p2->P4, 0x10000, pmm_alloc(), PAGE_PRESENT | PAGE_WRITE);
scheduler_insert(t1);
scheduler_insert(t2);
scheduler_insert(t3);
debug_info("BOOT COMPLETE\n");
schedule();