Nucleus
Barry Uninterruptable clone() 960f398 (3 years, 3 months ago)
diff --git a/memory/paging.c b/memory/paging.c
index cd6deb5..c7ebb30 100644
--- a/memory/paging.c
+++ b/memory/paging.c
@@ -55,7 +55,6 @@ clone_dir(void)
if (!(oldTables[tbl] & PDE_PRESENT))
continue;
-
/* Link kernel tables */
if (tbl < 2 || tbl >= 1008) {
newTables[tbl] = oldTables[tbl];
diff --git a/task/clone.c b/task/clone.c
index f7496c9..2d9b8ea 100644
--- a/task/clone.c
+++ b/task/clone.c
@@ -21,6 +21,8 @@ read_eip(void)
pid_t
clone(int flags)
{
+ asm volatile("cli");
+
Task *parent = current, *child = new(&taskType), *tmp;
pid_t tid = 0;
@@ -28,17 +30,13 @@ clone(int flags)
child->pageDir = clone_dir();
/* Split tasks here */
- uintptr_t esp, ebp, eip;
- eip = (uintptr_t) &&end;
-
- asm volatile("mov %%esp, %0" : "=r" (esp));
- asm volatile("mov %%ebp, %0" : "=r" (ebp));
- child->esp = esp;
- child->ebp = ebp;
- child->eip = eip;
+ child->eip = (uintptr_t) &&end;
+ asm volatile("mov %%esp, %0" : "=r" (child->esp));
+ asm volatile("mov %%ebp, %0" : "=r" (child->ebp));
add_to_queue(readyQueue[child->priority], child);
tid = child->tid;
put(child);
end:
+ asm volatile("sti");
return tid;
}
diff --git a/task/scheduler.c b/task/scheduler.c
index 37e8345..85cc904 100644
--- a/task/scheduler.c
+++ b/task/scheduler.c
@@ -26,19 +26,12 @@ read_eip(void)
static void
switch_to_task(Task *task)
{
- uintptr_t esp, ebp, eip;
- asm volatile("mov %%esp, %0" : "=r" (esp));
- asm volatile("mov %%ebp, %0" : "=r" (ebp));
- eip = (uintptr_t) &&end;
+ asm volatile("mov %%esp, %0" : "=r" (current->esp));
+ asm volatile("mov %%ebp, %0" : "=r" (current->ebp));
+ current->eip = (uintptr_t) &&end;
- current->esp = esp;
- current->ebp = ebp;
- current->eip = eip;
put(current);
current = task; /* Use the passed reference */
- esp = current->esp;
- ebp = current->ebp;
- eip = current->eip;
asm volatile (
"cli;"
@@ -48,7 +41,8 @@ switch_to_task(Task *task)
"movl %3, %%cr3;"
"sti;"
"jmp *%%ecx"
- :: "g" (eip), "g" (esp), "g" (ebp), "g" (current->pageDir)
+ :: "g" (current->eip), "g" (current->esp),
+ "g" (current->ebp), "g" (current->pageDir)
);
end:
}