Usermode/telnet - Moved to new routing API
[tpg/acess2.git] / Kernel / threads.c
index ee48e3e..62bb7e0 100644 (file)
@@ -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
@@ -1312,6 +1314,7 @@ int Mutex_Acquire(tMutex *Mutex)
 /**
  * \brief Release a held mutex
  * \param Mutex        Mutex to release
+ * \note Releasing a non-held mutex has no effect
  */
 void Mutex_Release(tMutex *Mutex)
 {
@@ -1359,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
@@ -1472,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;

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