Io: Change async thread priority if running.
Really thought I'd already done this, must've made a mistake... Fixes #12400.
This commit is contained in:
parent
4065fae262
commit
f63daf8185
5 changed files with 33 additions and 11 deletions
|
@ -87,6 +87,10 @@ bool HLEHelperThread::Stopped() {
|
||||||
return KernelIsThreadDormant(id_);
|
return KernelIsThreadDormant(id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HLEHelperThread::ChangePriority(u32 prio) {
|
||||||
|
KernelChangeThreadPriority(id_, prio);
|
||||||
|
}
|
||||||
|
|
||||||
void HLEHelperThread::Forget() {
|
void HLEHelperThread::Forget() {
|
||||||
id_ = 0;
|
id_ = 0;
|
||||||
entry_ = 0;
|
entry_ = 0;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void Start(u32 a0, u32 a1);
|
void Start(u32 a0, u32 a1);
|
||||||
void Terminate();
|
void Terminate();
|
||||||
bool Stopped();
|
bool Stopped();
|
||||||
|
void ChangePriority(u32 prio);
|
||||||
|
|
||||||
// For savestates.
|
// For savestates.
|
||||||
void Forget();
|
void Forget();
|
||||||
|
|
|
@ -1973,6 +1973,10 @@ static int sceIoChangeAsyncPriority(int id, int priority) {
|
||||||
return hleLogError(SCEIO, error, "bad file descriptor");
|
return hleLogError(SCEIO, error, "bad file descriptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (asyncThreads[id] && !asyncThreads[id]->Stopped()) {
|
||||||
|
asyncThreads[id]->ChangePriority(priority);
|
||||||
|
}
|
||||||
|
|
||||||
asyncParams[id].priority = priority;
|
asyncParams[id].priority = priority;
|
||||||
return hleLogSuccessI(SCEIO, 0);
|
return hleLogSuccessI(SCEIO, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2418,6 +2418,28 @@ int sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr) {
|
||||||
return hleLogSuccessI(SCEKERNEL, 0);
|
return hleLogSuccessI(SCEKERNEL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assumes validated parameters.
|
||||||
|
bool KernelChangeThreadPriority(SceUID threadID, int priority) {
|
||||||
|
u32 error;
|
||||||
|
Thread *thread = kernelObjects.Get<Thread>(threadID, error);
|
||||||
|
if (thread) {
|
||||||
|
int old = thread->nt.currentPriority;
|
||||||
|
threadReadyQueue.remove(old, threadID);
|
||||||
|
|
||||||
|
thread->nt.currentPriority = priority;
|
||||||
|
threadReadyQueue.prepare(thread->nt.currentPriority);
|
||||||
|
if (thread->isRunning()) {
|
||||||
|
thread->nt.status = (thread->nt.status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY;
|
||||||
|
}
|
||||||
|
if (thread->isReady()) {
|
||||||
|
threadReadyQueue.push_back(thread->nt.currentPriority, threadID);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int sceKernelChangeThreadPriority(SceUID threadID, int priority) {
|
int sceKernelChangeThreadPriority(SceUID threadID, int priority) {
|
||||||
if (threadID == 0) {
|
if (threadID == 0) {
|
||||||
threadID = __KernelGetCurThread();
|
threadID = __KernelGetCurThread();
|
||||||
|
@ -2444,17 +2466,7 @@ int sceKernelChangeThreadPriority(SceUID threadID, int priority) {
|
||||||
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_PRIORITY, "bogus priority");
|
return hleLogError(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_PRIORITY, "bogus priority");
|
||||||
}
|
}
|
||||||
|
|
||||||
int old = thread->nt.currentPriority;
|
KernelChangeThreadPriority(threadID, priority);
|
||||||
threadReadyQueue.remove(old, threadID);
|
|
||||||
|
|
||||||
thread->nt.currentPriority = priority;
|
|
||||||
threadReadyQueue.prepare(thread->nt.currentPriority);
|
|
||||||
if (thread->isRunning()) {
|
|
||||||
thread->nt.status = (thread->nt.status & ~THREADSTATUS_RUNNING) | THREADSTATUS_READY;
|
|
||||||
}
|
|
||||||
if (thread->isReady()) {
|
|
||||||
threadReadyQueue.push_back(thread->nt.currentPriority, threadID);
|
|
||||||
}
|
|
||||||
|
|
||||||
hleEatCycles(450);
|
hleEatCycles(450);
|
||||||
hleReSchedule("change thread priority");
|
hleReSchedule("change thread priority");
|
||||||
|
|
|
@ -162,6 +162,7 @@ KernelObject *__KernelCallbackObject();
|
||||||
void __KernelScheduleWakeup(int threadnumber, s64 usFromNow);
|
void __KernelScheduleWakeup(int threadnumber, s64 usFromNow);
|
||||||
SceUID __KernelGetCurThread();
|
SceUID __KernelGetCurThread();
|
||||||
int KernelCurThreadPriority();
|
int KernelCurThreadPriority();
|
||||||
|
bool KernelChangeThreadPriority(SceUID threadID, int priority);
|
||||||
u32 __KernelGetCurThreadStack();
|
u32 __KernelGetCurThreadStack();
|
||||||
u32 __KernelGetCurThreadStackStart();
|
u32 __KernelGetCurThreadStackStart();
|
||||||
const char *__KernelGetThreadName(SceUID threadID);
|
const char *__KernelGetThreadName(SceUID threadID);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue