Merge pull request #14073 from unknownbrackets/hle-delay

Log errors when delaying or waiting an already waiting thread
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2021-02-15 23:10:08 +01:00
commit e1d73b2b91
3 files changed
+35 -25

No files matched your search

+17 -10
View File
@@ -1210,7 +1210,15 @@ bool KernelIsThreadDormant(SceUID threadID) {
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
if (t)
return (t->nt.status & (THREADSTATUS_DEAD | THREADSTATUS_DORMANT)) != 0;
return 0;
return false;
}
bool KernelIsThreadWaiting(SceUID threadID) {
u32 error;
PSPThread *t = kernelObjects.Get<PSPThread>(threadID, error);
if (t)
return (t->nt.status & (THREADSTATUS_WAITSUSPEND)) != 0;
return false;
}
u32 __KernelGetWaitValue(SceUID threadID, u32 &error) {
@@ -1518,16 +1526,16 @@ u32 __KernelResumeThreadFromWait(SceUID threadID, u64 retval)
}
// makes the current thread wait for an event
void __KernelWaitCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 timeoutPtr, bool processCallbacks, const char *reason)
{
if (!dispatchEnabled)
{
void __KernelWaitCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 timeoutPtr, bool processCallbacks, const char *reason) {
if (!dispatchEnabled) {
WARN_LOG_REPORT(SCEKERNEL, "Ignoring wait, dispatching disabled... right thing to do?");
return;
}
PSPThread *thread = __GetCurrentThread();
_assert_(thread != nullptr);
if ((thread->nt.status & THREADSTATUS_WAIT) != 0)
WARN_LOG_REPORT(SCEKERNEL, "Waiting thread for %d that was already waiting for %d", type, thread->nt.waitType);
thread->nt.waitID = waitID;
thread->nt.waitType = type;
__KernelChangeThreadState(thread, ThreadStatus(THREADSTATUS_WAIT | (thread->nt.status & THREADSTATUS_SUSPEND)));
@@ -1535,22 +1543,21 @@ void __KernelWaitCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 time
thread->waitInfo.waitValue = waitValue;
thread->waitInfo.timeoutPtr = timeoutPtr;
// TODO: time waster
if (!reason)
reason = "started wait";
hleReSchedule(processCallbacks, reason);
}
void __KernelWaitCallbacksCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 timeoutPtr)
{
if (!dispatchEnabled)
{
void __KernelWaitCallbacksCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 timeoutPtr) {
if (!dispatchEnabled) {
WARN_LOG_REPORT(SCEKERNEL, "Ignoring wait, dispatching disabled... right thing to do?");
return;
}
PSPThread *thread = __GetCurrentThread();
if ((thread->nt.status & THREADSTATUS_WAIT) != 0)
WARN_LOG_REPORT(SCEKERNEL, "Waiting thread for %d that was already waiting for %d", type, thread->nt.waitType);
thread->nt.waitID = waitID;
thread->nt.waitType = type;
__KernelChangeThreadState(thread, ThreadStatus(THREADSTATUS_WAIT | (thread->nt.status & THREADSTATUS_SUSPEND)));