コード例 #1
0
ファイル: coreinit_thread.cpp プロジェクト: lioncash/wiiu-emu
void
OSWakeupThread(OSThreadQueue *queue)
{
   OSLockScheduler();
   OSWakeupThreadNoLock(queue);
   OSUnlockScheduler();
}
コード例 #2
0
ファイル: coreinit_event.cpp プロジェクト: Subv/decaf-emu
/**
 * Signal the event and wakeup all waiting threads regardless of mode
 *
 * This differs to OSSignalEvent only for auto reset mode where it
 * will wake up all threads instead of just one.
 *
 * If there is at least one thread woken up and the alarm is in
 * auto reset mode then the event value is reset to FALSE.
 */
void
OSSignalEventAll(OSEvent *event)
{
   OSLockScheduler();
   assert(event);
   assert(event->tag == OSEvent::Tag);

   if (event->value != FALSE) {
      // Event has already been set
      OSUnlockScheduler();
      return;
   }

   // Set event
   event->value = TRUE;

   if (!OSIsThreadQueueEmpty(&event->queue)) {
      if (event->mode == OSEventMode::AutoReset) {
         // Reset event
         event->value = FALSE;
      }

      // Wakeup all threads
      OSWakeupThreadNoLock(&event->queue);
      OSRescheduleNoLock();
   }

   OSUnlockScheduler();
}
コード例 #3
0
int32_t
OSSignalSemaphore(OSSemaphore *semaphore)
{
   int32_t previous;
   OSLockScheduler();
   assert(semaphore && semaphore->tag == OSSemaphore::Tag);

   // Increase semaphore
   previous =  semaphore->count++;

   // Wakeup any waiting threads
   OSWakeupThreadNoLock(&semaphore->queue);
   OSRescheduleNoLock();

   OSUnlockScheduler();
   return previous;
}
コード例 #4
0
ファイル: coreinit_thread.cpp プロジェクト: aspico/wiiu-emu
void
OSExitThread(int value)
{
   auto thread = OSGetCurrentThread();
   OSLockScheduler();
   thread->exitValue = value;

   if (thread->attr & OSThreadAttributes::Detached) {
      thread->state = OSThreadState::None;
   } else {
      thread->state = OSThreadState::Moribund;
   }

   OSWakeupThreadNoLock(&thread->joinQueue);
   OSWakeupThreadWaitForSuspensionNoLock(&thread->suspendQueue, -1);
   OSUnlockScheduler();
   gProcessor.exit();
}
コード例 #5
0
ファイル: coreinit_mutex.cpp プロジェクト: Subv/decaf-emu
void
OSUnlockMutexNoLock(OSMutex *mutex)
{
   auto thread = OSGetCurrentThread();
   assert(mutex && mutex->tag == OSMutex::Tag);
   assert(mutex->owner == thread);
   assert(mutex->count > 0);
   mutex->count--;

   if (mutex->count == 0) {
      mutex->owner = nullptr;

      // Remove mutex from thread's mutex queue
      OSEraseFromQueue(&thread->mutexQueue, mutex);

      // Wakeup any threads trying to lock this mutex
      OSWakeupThreadNoLock(&mutex->queue);
      OSRescheduleNoLock();
   }
}