+void Semaphore_ForceWake(tThread *Thread)
+{
+ if( !CPU_HAS_LOCK(&Thread->IsLocked) ) {
+ Log_Error("Semaphore", "Force wake should be called with the thread lock held");
+ return ;
+ }
+ if( Thread->Status != THREAD_STAT_SEMAPHORESLEEP ) {
+ Log_Error("Semaphore", "_ForceWake called on non-semaphore thread");
+ return ;
+ }
+
+ tSemaphore *sem = Thread->WaitPointer;
+ SHORTLOCK( &sem->Protector );
+ tThread *prev = NULL;
+ if( sem->Waiting == Thread )
+ sem->Waiting = sem->Waiting->Next;
+ else
+ {
+ for( prev = sem->Waiting; prev && prev->Next != Thread; prev = prev->Next )
+ ;
+ if( prev )
+ prev->Next = Thread->Next;
+ }
+ if( sem->LastWaiting == Thread )
+ sem->LastWaiting = prev;
+ SHORTREL( &sem->Protector );
+ Thread->RetStatus = 0;
+ Threads_AddActive(Thread);
+}
+