Process events when idle or switching threads.
Fixes hrydgard/ppsspp#104, so things execute more accurately.
This commit is contained in:
parent
998104e2eb
commit
a2ee736793
2 changed files with 23 additions and 1 deletions
|
@ -500,6 +500,20 @@ void Idle(int maxIdle)
|
||||||
if (maxIdle != 0 && cyclesDown > maxIdle)
|
if (maxIdle != 0 && cyclesDown > maxIdle)
|
||||||
cyclesDown = maxIdle;
|
cyclesDown = maxIdle;
|
||||||
|
|
||||||
|
if (first && cyclesDown > 0)
|
||||||
|
{
|
||||||
|
int cyclesExecuted = slicelength - downcount;
|
||||||
|
int cyclesNextEvent = (int) (first->time - globalTimer);
|
||||||
|
|
||||||
|
if (cyclesNextEvent < cyclesExecuted + cyclesDown)
|
||||||
|
{
|
||||||
|
cyclesDown = cyclesNextEvent - cyclesExecuted;
|
||||||
|
// Now, now... no time machines, please.
|
||||||
|
if (cyclesDown < 0)
|
||||||
|
cyclesDown = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_LOG(CPU, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(CPU_HZ * 0.001f));
|
DEBUG_LOG(CPU, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(CPU_HZ * 0.001f));
|
||||||
|
|
||||||
idledCycles += cyclesDown;
|
idledCycles += cyclesDown;
|
||||||
|
@ -520,7 +534,7 @@ std::string GetScheduledEventsSummary()
|
||||||
if (!name)
|
if (!name)
|
||||||
name = "[unknown]";
|
name = "[unknown]";
|
||||||
char temp[512];
|
char temp[512];
|
||||||
sprintf(temp, "%s : %i %08x%08x\n", event_types[ptr->type].name, (int)ptr->time, (u32)(ptr->userdata >> 32), (u32)(ptr->userdata));
|
sprintf(temp, "%s : %i %08x%08x\n", name, (int)ptr->time, (u32)(ptr->userdata >> 32), (u32)(ptr->userdata));
|
||||||
text += temp;
|
text += temp;
|
||||||
ptr = ptr->next;
|
ptr = ptr->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,6 +730,14 @@ void __KernelReSchedule(const char *reason)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute any pending events while we're doing scheduling.
|
||||||
|
CoreTiming::Advance();
|
||||||
|
if (__IsInInterrupt() || __KernelInCallback())
|
||||||
|
{
|
||||||
|
reason = "In Interrupt Or Callback";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
Thread *nextThread = __KernelNextThread();
|
Thread *nextThread = __KernelNextThread();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue