Cancel wakeup events when a thread ends.

This commit is contained in:
Unknown W. Brackets 2012-12-01 14:36:56 -08:00
parent 573aba2fb9
commit 8bae2e0964

View File

@ -265,6 +265,7 @@ void __KernelExecuteMipsCallOnCurrentThread(int callId);
int g_inCbCount = 0;
Thread *__KernelCreateThread(SceUID &id, SceUID moduleID, const char *name, u32 entryPoint, u32 priority, int stacksize, u32 attr);
void __KernelCancelWakeup(SceUID threadID);
//////////////////////////////////////////////////////////////////////////
//STATE BEGIN
@ -344,6 +345,8 @@ void __KernelThreadingInit()
__KernelCreateThread(threadIdleID[0], 0, "idle0", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL);
__KernelCreateThread(threadIdleID[1], 0, "idle1", idleThreadHackAddr, 0x7f, 4096, PSP_THREAD_ATTR_KERNEL);
// These idle threads are later started in LoadExec, which calls __KernelStartIdleThreads below.
__KernelListenThreadEnd(__KernelCancelWakeup);
}
void __KernelListenThreadEnd(ThreadCallback callback)
@ -683,6 +686,11 @@ void __KernelScheduleWakeup(SceUID threadID, int usFromNow)
CoreTiming::ScheduleEvent(usToCycles(usFromNow), eventScheduledWakeup, threadID);
}
void __KernelCancelWakeup(SceUID threadID)
{
CoreTiming::UnscheduleEvent(eventScheduledWakeup, threadID);
}
void __KernelRemoveFromThreadQueue(Thread *t)
{
for (size_t i = 0; i < threadqueue.size(); i++)