Major build system changes
[tpg/acess2.git] / Kernel / threads.c
index aac6648..10226a1 100644 (file)
@@ -124,6 +124,7 @@ void Threads_Init(void)
        
        Log_Debug("Threads", "Offsets of tThread");
        Log_Debug("Threads", ".Priority = %i", offsetof(tThread, Priority));
+       Log_Debug("Threads", ".KernelStack = %i", offsetof(tThread, KernelStack));
        
        // Create Initial Task
        #if SCHEDULER_TYPE == SCHED_RR_PRI
@@ -716,8 +717,11 @@ void Threads_Sleep(void)
        // Release Spinlock
        SHORTREL( &glThreadListLock );
 
-       while(cur->Status != THREAD_STAT_ACTIVE)
+       while(cur->Status != THREAD_STAT_ACTIVE) {
                Proc_Reschedule();
+               if( cur->Status != THREAD_STAT_ACTIVE )
+                       Log("%i - Huh? why am I up? zzzz...", cur->TID);
+       }
 }
 
 
@@ -999,7 +1003,7 @@ void Threads_SegFault(tVAddr Addr)
        tThread *cur = Proc_GetCurThread();
        cur->bInstrTrace = 0;
        Log_Warning("Threads", "Thread #%i committed a segfault at address %p", cur->TID, Addr);
-       MM_DumpTables(0, KERNEL_BASE);
+       MM_DumpTables(0, USER_MAX);
        Threads_Fault( 1 );
        //Threads_Exit( 0, -1 );
 }
@@ -1292,7 +1296,7 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last)
                        }
                        // If we fall onto the same queue again, special handling is
                        // needed
-                       if( Last && i == Last->Priority ) {
+                       if( Last && Last->Status == THREAD_STAT_ACTIVE && i == Last->Priority ) {
                                tThread *savedThread = thread;
                                
                                // Find the next unscheduled thread in the list
@@ -1313,6 +1317,9 @@ tThread *Threads_GetNextToRun(int CPU, tThread *Last)
                        SHORTREL(&glThreadListLock);
                        return NULL;
                }
+               if( thread->Status != THREAD_STAT_ACTIVE ) {
+                       LogF("Oops, Thread %i (%s) is not active\n", thread->TID, thread->ThreadName);
+               }
        }
        #elif SCHEDULER_TYPE == SCHED_RR_SIM
        {               

UCC git Repository :: git.ucc.asn.au