aboutsummaryrefslogtreecommitdiff
path: root/src/core/scheduler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/scheduler.cc')
-rw-r--r--src/core/scheduler.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/core/scheduler.cc b/src/core/scheduler.cc
new file mode 100644
index 0000000..00741fe
--- /dev/null
+++ b/src/core/scheduler.cc
@@ -0,0 +1,40 @@
+#include "scheduler.hpp"
+
+TASK tasks[MAX_TASK];
+u32 ntasks=0;
+char show_ticks=0;
+
+extern "C" void clock(){
+ if(show_ticks)
+ print(".");
+}
+void schedule(){
+
+}
+
+
+void create_task(void* task, u32 size){
+ if(ntasks>=MAX_TASK){
+ printk("Could not create more tasks.");
+ return;
+ }
+
+ TASK *t=&tasks[ntasks];
+ t->id=ntasks;
+ t->pid=ntasks;
+ t->size=size;
+ t->pml4=paging_create_task(size/4096+1);
+
+ // Load task using
+ lpml4(t->pml4);
+ memcpy(task, TASK_VMA, size);
+ lpml4(kpml4);
+
+ ntasks++;
+}
+
+void scheduler_start(){
+ TASK *t=&tasks[0];
+ lpml4(t->pml4);
+ asm("jmp switch");
+} \ No newline at end of file