More threading fixes

This commit is contained in:
wheremyfoodat
2023-08-01 23:45:43 +03:00
parent 7047bf6ec8
commit 65de2637ae
3 changed files with 24 additions and 15 deletions

View File

@@ -76,6 +76,11 @@ void Kernel::sendSyncRequest() {
u32 messagePointer = getTLSPointer() + 0x80; // The message is stored starting at TLS+0x80
logSVC("SendSyncRequest(session handle = %X)\n", handle);
// Service calls via SendSyncRequest and file access needs to put the caller to sleep for a given amount of time
// To make sure that the other threads don't get starved. Various games rely on this (including Sonic Boom: Shattering Crystal it seems)
constexpr u64 syncRequestDelayNs = 39000;
sleepThread(syncRequestDelayNs);
// The sync request is being sent at a service rather than whatever port, so have the service manager intercept it
if (KernelHandles::isServiceHandle(handle)) {
// The service call might cause a reschedule and change threads. Hence, set r0 before executing the service call