# include <mp.h>
#endif
+// === FLAGS ===
+#define DEBUG_TRACE_SWITCH 0
+
// === CONSTANTS ===
#define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area
#define TIMER_DIVISOR 11931 //~100Hz
extern tThread *gSleepingThreads;
extern tThread *gDeleteThreads;
extern tThread *Threads_GetNextToRun(int CPU);
+extern void Threads_Dump();
// === PROTOTYPES ===
void ArchThreads_Init();
gThreadZero.MemState.PDP[1] = 0;
gThreadZero.MemState.PDP[2] = 0;
#else
- gThreadZero.MemState.CR3 = (Uint)gaInitPageDir;
+ gThreadZero.MemState.CR3 = (Uint)gaInitPageDir - KERNEL_BASE;
#endif
// Set timer frequency
giTotalTickets += newThread->NumTickets;
RELEASE( &giThreadListLock );
+ Threads_Dump();
+
return newThread->TID;
}
// Check if there is any tasks running
if(giNumActiveThreads == 0) {
- Log("No Active threads, sleeping\n");
+ Log("No Active threads, sleeping");
__asm__ __volatile__ ("hlt");
return;
}
return;
}
+ #if DEBUG_TRACE_SWITCH
+ Log("Switching to task %i, CR3 = 0x%x, EIP = %p",
+ thread->TID,
+ thread->MemState.CR3,
+ thread->SavedState.EIP
+ );
+ #endif
+
// Set current thread
gCurrentThread = thread;