X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fproc.c;h=76e96c93630607f8c69767ec72cd7ea8ed63f07e;hb=8fbb4dea9912d22c1758d38b843e406a263fdd42;hp=bdce0ca2bac318e951faefd9c3809769db3014aa;hpb=a3d9c32b28b6a6fd90a0b181a02def095eaaaec6;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/proc.c b/Kernel/arch/x86/proc.c index bdce0ca2..76e96c93 100644 --- a/Kernel/arch/x86/proc.c +++ b/Kernel/arch/x86/proc.c @@ -10,6 +10,9 @@ # include #endif +// === FLAGS === +#define DEBUG_TRACE_SWITCH 0 + // === CONSTANTS === #define SWITCH_MAGIC 0xFFFACE55 // There is no code in this area #define TIMER_DIVISOR 11931 //~100Hz @@ -29,6 +32,7 @@ extern tThread *gActiveThreads; extern tThread *gSleepingThreads; extern tThread *gDeleteThreads; extern tThread *Threads_GetNextToRun(int CPU); +extern void Threads_Dump(); // === PROTOTYPES === void ArchThreads_Init(); @@ -136,7 +140,7 @@ 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 @@ -305,12 +309,9 @@ int Proc_Clone(Uint *Err, Uint Flags) newThread->SavedState.EIP = eip; // Lock list and add to active - LOCK( &giThreadListLock ); - newThread->Next = gActiveThreads; - gActiveThreads = newThread; - giNumActiveThreads ++; - giTotalTickets += newThread->NumTickets; - RELEASE( &giThreadListLock ); + Threads_AddActive(newThread); + + Threads_Dump(); return newThread->TID; } @@ -464,7 +465,7 @@ void Proc_Scheduler(int CPU) // 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; } @@ -494,6 +495,14 @@ void Proc_Scheduler(int CPU) 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;