void Thread::Stop() { // Release all the mutexes that this thread holds ReleaseThreadMutexes(this); // Cancel any outstanding wakeup events for this thread CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); wakeup_callback_handle_table.Close(callback_handle); callback_handle = 0; // Clean up thread from ready queue // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) if (status == THREADSTATUS_READY){ ready_queue.remove(current_priority, this); } status = THREADSTATUS_DEAD; WakeupAllWaitingThreads(); // Clean up any dangling references in objects that this thread was waiting for for (auto& wait_object : wait_objects) { wait_object->RemoveWaitingThread(this); } wait_objects.clear(); // Mark the TLS slot in the thread's page as free. u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; u32 tls_slot = ((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot); HLE::Reschedule(__func__); }
ResultVal<s32> Semaphore::Release(s32 release_count) { if (max_count - available_count < release_count) return ERR_OUT_OF_RANGE_KERNEL; s32 previous_count = available_count; available_count += release_count; WakeupAllWaitingThreads(); return MakeResult<s32>(previous_count); }
void Timer::Signal(int cycles_late) { LOG_TRACE(Kernel, "Timer %u fired", GetObjectId()); signaled = true; // Resume all waiting threads WakeupAllWaitingThreads(); if (interval_delay != 0) { // Reschedule the timer with the interval delay u64 interval_microseconds = interval_delay / 1000; CoreTiming::ScheduleEvent(usToCycles(interval_microseconds) - cycles_late, timer_callback_event_type, callback_handle); } }
void Thread::Stop() { // Release all the mutexes that this thread holds ReleaseThreadMutexes(this); // Cancel any outstanding wakeup events for this thread CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); // Clean up thread from ready queue // This is only needed when the thread is termintated forcefully (SVC TerminateProcess) if (status == THREADSTATUS_READY){ ready_queue.remove(current_priority, this); } status = THREADSTATUS_DEAD; WakeupAllWaitingThreads(); // Clean up any dangling references in objects that this thread was waiting for for (auto& wait_object : wait_objects) { wait_object->RemoveWaitingThread(this); } }
void Event::Signal() { signaled = true; WakeupAllWaitingThreads(); }