Merge pull request #12533 from unknownbrackets/io-async

Io: Allow adjusting default async thread priority
This commit is contained in:
Henrik Rydgård 2019-12-26 22:19:51 +01:00 committed by GitHub
commit 0a5ec48382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,6 +199,7 @@ struct IoAsyncParams {
static IoAsyncParams asyncParams[PSP_COUNT_FDS];
static HLEHelperThread *asyncThreads[PSP_COUNT_FDS]{};
static int asyncDefaultPriority = -1;
class FileNode : public KernelObject {
public:
@ -662,7 +663,7 @@ void __IoInit() {
}
void __IoDoState(PointerWrap &p) {
auto s = p.Section("sceIo", 1, 4);
auto s = p.Section("sceIo", 1, 5);
if (!s)
return;
@ -721,6 +722,12 @@ void __IoDoState(PointerWrap &p) {
clearThread();
}
}
if (s >= 5) {
p.Do(asyncDefaultPriority);
} else {
asyncDefaultPriority = -1;
}
}
void __IoShutdown() {
@ -738,6 +745,7 @@ void __IoShutdown() {
delete asyncThreads[i];
asyncThreads[i] = nullptr;
}
asyncDefaultPriority = -1;
pspFileSystem.Unmount("ms0:", memstickSystem);
pspFileSystem.Unmount("fatms0:", memstickSystem);
@ -771,7 +779,9 @@ u32 __IoGetFileHandleFromId(u32 id, u32 &outError)
static void IoStartAsyncThread(int id, FileNode *f) {
IoAsyncCleanupThread(id, true);
int priority = asyncParams[id].priority == -1 ? KernelCurThreadPriority() : asyncParams[id].priority;
int priority = asyncParams[id].priority == -1 ? asyncDefaultPriority : asyncParams[id].priority;
if (priority == -1)
priority = KernelCurThreadPriority();
asyncThreads[id] = new HLEHelperThread("SceIoAsync", "IoFileMgrForUser", "__IoAsyncFinish", priority, 0x200);
asyncThreads[id]->Start(id, 0);
f->pendingAsyncResult = true;
@ -1962,6 +1972,11 @@ static int sceIoChangeAsyncPriority(int id, int priority) {
return hleLogError(SCEIO, SCE_KERNEL_ERROR_ILLEGAL_PRIORITY, "illegal priority %d", priority);
}
if (id == -1) {
asyncDefaultPriority = priority;
return hleLogSuccessI(SCEIO, 0);
}
u32 error;
FileNode *f = __IoGetFd(id, error);
if (!f) {