extern Uint GetRIP(void); // start.asm
extern Uint64 gInitialPML4[512]; // start.asm
extern char gInitialKernelStack[];
-extern tSpinlock glThreadListLock;
+extern tShortSpinlock glThreadListLock;
extern int giNumCPUs;
extern int giNextTID;
extern int giTotalTickets;
}
#endif
+ // Set Debug registers
+ __asm__ __volatile__ ("mov %0, %%db0" : : "r"(&gThreadZero));
+ __asm__ __volatile__ ("mov %%rax, %%db1" : : "a"(0));
+
gaCPUs[0].Current = &gThreadZero;
gThreadZero.MemState.CR3 = (Uint)gInitialPML4 - KERNEL_BASE;
+ gThreadZero.CurCPU = 0;
// Set timer frequency
outb(0x43, 0x34); // Set Channel 0, Low/High, Rate Generator
// Change Stacks
Proc_ChangeStack();
+
+ Log("Multithreading initialised");
}
#if USE_MP
// Set current task
gaCPUs[0].Current = &gThreadZero;
+ gaCPUs[0].Current->CurCPU = 0;
// Start Interrupts (and hence scheduler)
__asm__ __volatile__("sti");
#endif
MM_FinishVirtualInit();
+ Log("Multithreading started");
}
/**
// If the spinlock is set, let it complete
if(IS_LOCKED(&glThreadListLock)) return;
-
+
// Get current thread
thread = gaCPUs[CPU].Current;