mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
[Kernel] Implement SetThreadPriority
This commit is contained in:
parent
bb9a50ab31
commit
1147824709
3 changed files with 29 additions and 0 deletions
|
@ -98,6 +98,7 @@ class Kernel {
|
|||
void getThreadPriority();
|
||||
void releaseMutex();
|
||||
void sendSyncRequest();
|
||||
void setThreadPriority();
|
||||
void signalEvent();
|
||||
void svcCloseHandle();
|
||||
void svcSleepThread();
|
||||
|
|
|
@ -25,6 +25,7 @@ void Kernel::serviceSVC(u32 svc) {
|
|||
case 0x08: createThread(); break;
|
||||
case 0x0A: svcSleepThread(); break;
|
||||
case 0x0B: getThreadPriority(); break;
|
||||
case 0x0C: setThreadPriority(); break;
|
||||
case 0x13: createMutex(); break;
|
||||
case 0x14: releaseMutex(); break;
|
||||
case 0x17: createEvent(); break;
|
||||
|
|
|
@ -231,6 +231,33 @@ void Kernel::getThreadPriority() {
|
|||
}
|
||||
}
|
||||
|
||||
void Kernel::setThreadPriority() {
|
||||
const Handle handle = regs[0];
|
||||
const u32 priority = regs[1];
|
||||
log("SetThreadPriority (handle = %X, priority = %X)\n", handle, priority);
|
||||
|
||||
if (priority > 0x3F) {
|
||||
regs[0] = SVCResult::BadThreadPriority;
|
||||
return;
|
||||
}
|
||||
|
||||
if (handle == KernelHandles::CurrentThread) {
|
||||
regs[0] = SVCResult::Success;
|
||||
threads[currentThreadIndex].priority = priority;
|
||||
} else {
|
||||
auto object = getObject(handle, KernelObjectType::Thread);
|
||||
if (object == nullptr) [[unlikely]] {
|
||||
regs[0] = SVCResult::BadHandle;
|
||||
return;
|
||||
} else {
|
||||
regs[0] = SVCResult::Success;
|
||||
object->getData<Thread>()->priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
rescheduleThreads();
|
||||
}
|
||||
|
||||
void Kernel::createMutex() {
|
||||
bool locked = regs[1] != 0;
|
||||
Helpers::panic("CreateMutex (initially locked: %s)\n", locked ? "yes" : "no");
|
||||
|
|
Loading…
Add table
Reference in a new issue