Skip to content

Commit

Permalink
Kernel: Adjust sceKernelGetThreadExitStatus timing.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Jan 19, 2021
1 parent a88f6b4 commit dd2bd55
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Core/HLE/sceKernelThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit dd2bd55

Please sign in to comment.