Kernel: Adjust sceKernelGetThreadExitStatus timing.

See #13703.
This commit is contained in:
Unknown W. Brackets 2021-01-18 22:09:37 -08:00
parent a88f6b45d2
commit dd2bd55bcb

View file

@ -1336,32 +1336,21 @@ u32 sceKernelReferThreadRunStatus(u32 threadID, u32 statusPtr)
int __KernelGetThreadExitStatus(SceUID threadID) {
u32 error;
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
if (t)
{
if (t->nt.status == THREADSTATUS_DORMANT) // TODO: can be dormant before starting, too, need to avoid that
{
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus(%d)", threadID);
return t->nt.exitStatus;
}
else
{
DEBUG_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus(%d): not dormant", threadID);
return SCE_KERNEL_ERROR_NOT_DORMANT;
}
if (!t) {
return hleLogError(SCEKERNEL, error);
}
else
{
ERROR_LOG(SCEKERNEL, "sceKernelGetThreadExitStatus Error %08x", error);
return SCE_KERNEL_ERROR_UNKNOWN_THID;
// __KernelResetThread and __KernelCreateThread set exitStatus in case it's DORMANT.
if (t->nt.status == THREADSTATUS_DORMANT) {
return hleLogSuccessI(SCEKERNEL, t->nt.exitStatus);
}
return hleLogDebug(SCEKERNEL, SCE_KERNEL_ERROR_NOT_DORMANT, "not dormant");
}
int sceKernelGetThreadExitStatus(SceUID threadID)
{
int sceKernelGetThreadExitStatus(SceUID threadID) {
u32 status = __KernelGetThreadExitStatus(threadID);
// Seems this is called in a tight-ish loop, maybe awaiting an interrupt - issue #13698
// Guess based on sceKernelGetThreadId.
hleEatCycles(180);
hleEatCycles(330);
return status;
}