BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / c738dbb1e7e7a46a98436326234826eef71083e2 / task

// Related

Nucleus

Barry CPU specific segment c738dbb (3 years, 2 months ago)
diff --git a/task/clone.c b/task/clone.c
index 93c0b94..7f23de3 100644
--- a/task/clone.c
+++ b/task/clone.c
@@ -73,7 +73,7 @@ clone(int flags)
 	put(child);
 	exit_critical_section();
 end:
-	if (tid && !current->inSyscall) {
+	if (!tid && !current->inSyscall) {
 		outb(0x20, 0x20);
 		if (apic)
 			LAPIC(0xB0) = 0;
diff --git a/task/scheduler.c b/task/scheduler.c
index b35192c..02413bd 100644
--- a/task/scheduler.c
+++ b/task/scheduler.c
@@ -15,6 +15,8 @@ void context_switch(uintptr_t eip, page_dir_t pagedir,
                     uintptr_t esi, uintptr_t edi, uintptr_t ebx,
                     uintptr_t ebp, uintptr_t esp);
 
+extern uint8_t slice[];
+
 ObjectList *readyQueue[PRIORITY_COUNT];
 
 /* Switch to a task */
@@ -64,6 +66,7 @@ schedule(void)
 
 	Task *task = current;
 	ObjectList *queue = highest_priority_queue();
+	slice[cpu->id] = 0;
 
 	/* Idle if necessary */
 	if (!queue) {
diff --git a/task/syscall.c b/task/syscall.c
index 8e33ef4..effe6c2 100644
--- a/task/syscall.c
+++ b/task/syscall.c
@@ -113,7 +113,13 @@ syscall_handler(struct InterruptFrame *frame)
 	}
 
 	/* Call function */
-	asm volatile("call *%1" : "=a" (ret) : "r" (syscall->function));
+	asm volatile(
+		"sti;"
+		"call *%1;"
+		"cli"
+		: "=a" (ret)
+		: "r" (syscall->function)
+	);
 
 end:
 	exit_syscall_context();
diff --git a/task/time.c b/task/time.c
index 3f5a50a..d6a47d9 100644
--- a/task/time.c
+++ b/task/time.c
@@ -15,16 +15,16 @@ uint8_t slice[MAX_CPUS] = {0};
 void
 timer_handler(struct InterruptFrame *frame)
 {
-	if (CPUID == 0)
+	if (cpu->id == 0)
 		monotonic++;
 
 	if (!current)
 		return;
-	slice[CPUID]++;
+	slice[cpu->id]++;
 
 	/* Call scheduler */
-	if (slice[CPUID] < (current->priority * 10))
+	if (slice[cpu->id] < (current->priority * 10))
 		return;
-	slice[CPUID] = 0;
+	slice[cpu->id] = 0;
 	schedule();
 }