X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fthreads.c;h=d24af08238b89d436862581797d854f9db33725d;hb=be6e3ccd05add9ad319a121661c20cb4769f58d7;hp=cafb8068d2d92471378c858fea516a1116a22b0a;hpb=e573d30162c179edc6de7b7c8364a617d9f25f77;p=tpg%2Facess2.git diff --git a/Kernel/threads.c b/Kernel/threads.c index cafb8068..d24af082 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -81,11 +81,11 @@ void Mutex_Release(tMutex *Mutex); // -- Core Thread -- // Only used for the core kernel tThread gThreadZero = { - Status: THREAD_STAT_ACTIVE, // Status - ThreadName: (char*)"ThreadZero", // Name - Quantum: DEFAULT_QUANTUM, // Default Quantum - Remaining: DEFAULT_QUANTUM, // Current Quantum - Priority: DEFAULT_PRIORITY // Number of tickets + .Status = THREAD_STAT_ACTIVE, // Status + .ThreadName = (char*)"ThreadZero", // Name + .Quantum = DEFAULT_QUANTUM, // Default Quantum + .Remaining = DEFAULT_QUANTUM, // Current Quantum + .Priority = DEFAULT_PRIORITY // Number of tickets }; // -- Processes -- // --- Locks --- @@ -782,6 +782,8 @@ void Threads_AddActive(tThread *Thread) tThread *cur = Proc_GetCurThread(); Warning("WTF, CPU%i %p (%i %s) is adding %p (%i %s) when it is active", GetCPUNum(), cur, cur->TID, cur->ThreadName, Thread, Thread->TID, Thread->ThreadName); + SHORTREL( &glThreadListLock ); + return ; } // Set state @@ -1360,9 +1362,11 @@ int Mutex_IsLocked(tMutex *Mutex) // void Semaphore_Init(tSemaphore *Sem, int Value, int MaxValue, const char *Module, const char *Name) { + memset(Sem, 0, sizeof(tSemaphore)); Sem->Value = Value; Sem->ModName = Module; Sem->Name = Name; + Sem->MaxValue = MaxValue; } // // Wait for items to be avaliable @@ -1473,8 +1477,12 @@ int Semaphore_Signal(tSemaphore *Sem, int AmmountToAdd) if( Sem->MaxValue && Sem->Value == Sem->MaxValue ) { tThread *us; - SHORTLOCK( &glThreadListLock ); + #if 0 + Log_Debug("Threads", "Semaphore_Signal: IDLE Sem = %s:%s", Sem->ModName, Sem->Name); + Log_Debug("Threads", "Semaphore_Signal: Sem->Value(%i) == Sem->MaxValue(%i)", Sem->Value, Sem->MaxValue); + #endif + SHORTLOCK( &glThreadListLock ); // - Remove from active list us = Threads_RemActive(); us->Next = NULL;