mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Improve some timing in msgpipes.
Probably not super important, but makes tests happier. Also, when unscheduling an event, return the current time left, including already spent time since last Advance.
This commit is contained in:
parent
a42a2864a6
commit
6599430c04
2 changed files with 18 additions and 4 deletions
|
@ -326,7 +326,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
|
|||
{
|
||||
if (first->type == event_type && first->userdata == userdata)
|
||||
{
|
||||
result = first->time - globalTimer;
|
||||
result = first->time - GetTicks();
|
||||
|
||||
Event *next = first->next;
|
||||
FreeEvent(first);
|
||||
|
@ -345,7 +345,7 @@ s64 UnscheduleEvent(int event_type, u64 userdata)
|
|||
{
|
||||
if (ptr->type == event_type && ptr->userdata == userdata)
|
||||
{
|
||||
result = ptr->time - globalTimer;
|
||||
result = ptr->time - GetTicks();
|
||||
|
||||
prev->next = ptr->next;
|
||||
FreeEvent(ptr);
|
||||
|
@ -371,7 +371,7 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
|
|||
{
|
||||
if (tsFirst->type == event_type && tsFirst->userdata == userdata)
|
||||
{
|
||||
result = tsFirst->time - globalTimer;
|
||||
result = tsFirst->time - GetTicks();
|
||||
|
||||
Event *next = tsFirst->next;
|
||||
FreeTsEvent(tsFirst);
|
||||
|
@ -394,7 +394,7 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
|
|||
{
|
||||
if (ptr->type == event_type && ptr->userdata == userdata)
|
||||
{
|
||||
result = ptr->time - globalTimer;
|
||||
result = ptr->time - GetTicks();
|
||||
|
||||
prev->next = ptr->next;
|
||||
if (ptr == tsLast)
|
||||
|
|
|
@ -729,6 +729,8 @@ int sceKernelCreateMsgPipe(const char *name, int partition, u32 attr, u32 size,
|
|||
|
||||
int sceKernelDeleteMsgPipe(SceUID uid)
|
||||
{
|
||||
hleEatCycles(900);
|
||||
|
||||
u32 error;
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m)
|
||||
|
@ -737,6 +739,10 @@ int sceKernelDeleteMsgPipe(SceUID uid)
|
|||
return error;
|
||||
}
|
||||
|
||||
hleEatCycles(3100);
|
||||
if (!m->sendWaitingThreads.empty() || !m->receiveWaitingThreads.empty())
|
||||
hleEatCycles(4000);
|
||||
|
||||
for (size_t i = 0; i < m->sendWaitingThreads.size(); i++)
|
||||
m->sendWaitingThreads[i].Cancel(uid, SCE_KERNEL_ERROR_WAIT_DELETE);
|
||||
for (size_t i = 0; i < m->receiveWaitingThreads.size(); i++)
|
||||
|
@ -785,6 +791,8 @@ int __KernelValidateSendMsgPipe(SceUID uid, u32 sendBufAddr, u32 sendSize, int w
|
|||
|
||||
int __KernelSendMsgPipe(MsgPipe *m, u32 sendBufAddr, u32 sendSize, int waitMode, u32 resultAddr, u32 timeoutPtr, bool cbEnabled, bool poll)
|
||||
{
|
||||
hleEatCycles(2400);
|
||||
|
||||
bool needsResched = false;
|
||||
bool needsWait = false;
|
||||
|
||||
|
@ -962,6 +970,8 @@ int sceKernelTryReceiveMsgPipe(SceUID uid, u32 receiveBufAddr, u32 receiveSize,
|
|||
|
||||
int sceKernelCancelMsgPipe(SceUID uid, u32 numSendThreadsAddr, u32 numReceiveThreadsAddr)
|
||||
{
|
||||
hleEatCycles(900);
|
||||
|
||||
u32 error;
|
||||
MsgPipe *m = kernelObjects.Get<MsgPipe>(uid, error);
|
||||
if (!m)
|
||||
|
@ -970,6 +980,10 @@ int sceKernelCancelMsgPipe(SceUID uid, u32 numSendThreadsAddr, u32 numReceiveThr
|
|||
return error;
|
||||
}
|
||||
|
||||
hleEatCycles(1100);
|
||||
if (!m->sendWaitingThreads.empty() || !m->receiveWaitingThreads.empty())
|
||||
hleEatCycles(4000);
|
||||
|
||||
if (Memory::IsValidAddress(numSendThreadsAddr))
|
||||
Memory::Write_U32((u32) m->sendWaitingThreads.size(), numSendThreadsAddr);
|
||||
if (Memory::IsValidAddress(numReceiveThreadsAddr))
|
||||
|
|
Loading…
Add table
Reference in a new issue