switch(Thread->Status)
{
case THREAD_STAT_ACTIVE:
- Log("Thread_Wake: Waking awake thread (%i)", Thread->TID);
+ Log("Threads_Wake - Waking awake thread (%i)", Thread->TID);
return -EALREADY;
case THREAD_STAT_SLEEPING:
return -EOK;
case THREAD_STAT_WAITING:
- Warning("Thread_Wake - Waiting threads are not currently supported");
+ Warning("Threads_Wake - Waiting threads are not currently supported");
return -ENOTIMPL;
case THREAD_STAT_DEAD:
- Warning("Thread_Wake - Attempt to wake dead thread (%i)", Thread->TID);
+ Warning("Threads_Wake - Attempt to wake dead thread (%i)", Thread->TID);
return -ENOTIMPL;
default:
- Warning("Thread_Wake - Unknown process status (%i)\n", Thread->Status);
+ Warning("Threads_Wake - Unknown process status (%i)\n", Thread->Status);
return -EINTERNAL;
}
}
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
/**
* \brief Release a held mutex
* \param Mutex Mutex to release
+ * \note Releasing a non-held mutex has no effect
*/
void Mutex_Release(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
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;