Merge pull request #3764 from unknownbrackets/scheduling

Improve dispatch/interrupt handling in start/create thread
This commit is contained in:
Henrik Rydgård 2013-09-14 02:57:09 -07:00
commit 3bc05a9941
2 changed files with 8 additions and 8 deletions

View File

@ -706,7 +706,7 @@ const HLEFunction ThreadManForUser[] =
{0x1AF94D03,0,"sceKernelDonateWakeupThread"},
{0xea748e31,WrapI_UU<sceKernelChangeCurrentThreadAttr>,"sceKernelChangeCurrentThreadAttr"},
{0x71bc9871,WrapI_II<sceKernelChangeThreadPriority>,"sceKernelChangeThreadPriority"},
{0x446D8DE6,WrapI_CUUIUU<sceKernelCreateThread>,"sceKernelCreateThread"},
{0x446D8DE6,WrapI_CUUIUU<sceKernelCreateThread>, "sceKernelCreateThread", HLE_NOT_IN_INTERRUPT},
{0x9fa03cd3,WrapI_I<sceKernelDeleteThread>,"sceKernelDeleteThread"},
{0xBD123D9E,WrapI_U<sceKernelDelaySysClockThread>, "sceKernelDelaySysClockThread", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED},
{0x1181E963,WrapI_U<sceKernelDelaySysClockThreadCB>, "sceKernelDelaySysClockThreadCB", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED},
@ -727,7 +727,7 @@ const HLEFunction ThreadManForUser[] =
{0x912354a7,&WrapI_I<sceKernelRotateThreadReadyQueue>,"sceKernelRotateThreadReadyQueue"},
{0x9ACE131E,WrapI_V<sceKernelSleepThread>, "sceKernelSleepThread", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED},
{0x82826f70,WrapI_V<sceKernelSleepThreadCB>, "sceKernelSleepThreadCB", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED},
{0xF475845D,&WrapI_IIU<sceKernelStartThread>,"sceKernelStartThread"},
{0xF475845D,&WrapI_IIU<sceKernelStartThread>, "sceKernelStartThread", HLE_NOT_IN_INTERRUPT},
{0x9944f31f,WrapI_I<sceKernelSuspendThread>,"sceKernelSuspendThread"},
{0x616403ba,WrapI_I<sceKernelTerminateThread>,"sceKernelTerminateThread"},
{0x383f7bcc,WrapI_I<sceKernelTerminateDeleteThread>,"sceKernelTerminateDeleteThread"},

View File

@ -2057,6 +2057,9 @@ int __KernelCreateThread(const char *threadName, SceUID moduleID, u32 entry, u32
if (optionAddr != 0)
WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateThread(name=%s): unsupported options parameter %08x", threadName, optionAddr);
// Creating a thread resumes dispatch automatically. Probably can't create without it.
dispatchEnabled = true;
hleEatCycles(32000);
// This won't schedule to the new thread, but it may to one woken from eating cycles.
// Technically, this should not eat all at once, and reschedule in the middle, but that's hard.
@ -2134,15 +2137,12 @@ int sceKernelStartThread(SceUID threadToStartID, int argSize, u32 argBlockPtr)
// Smaller is better for priority. Only switch if the new thread is better.
if (cur && cur->nt.currentPriority > startThread->nt.currentPriority)
{
// Starting a thread automatically resumes the dispatch thread.
// TODO: Maybe this happens even for worse-priority started threads?
dispatchEnabled = true;
__KernelChangeReadyState(cur, currentThread, true);
hleReSchedule("thread started");
}
else if (!dispatchEnabled)
WARN_LOG_REPORT(SCEKERNEL, "UNTESTED Dispatch disabled while starting worse-priority thread");
// Starting a thread automatically resumes the dispatch thread.
dispatchEnabled = true;
__KernelChangeReadyState(startThread, threadToStartID, true);
return 0;