summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2017-12-31 15:58:16 -0500
committerGravatar bunnei2017-12-31 15:58:16 -0500
commit8a7f8f3e2cdb71b5e67e15ffdd3ad8679ebfb2fc (patch)
tree6efcffc442da9524e3e727a2fe733b801dbdd323
parentsvc: Change SignalProcessWideKey to a stub. (diff)
downloadyuzu-8a7f8f3e2cdb71b5e67e15ffdd3ad8679ebfb2fc.tar.gz
yuzu-8a7f8f3e2cdb71b5e67e15ffdd3ad8679ebfb2fc.tar.xz
yuzu-8a7f8f3e2cdb71b5e67e15ffdd3ad8679ebfb2fc.zip
svc: Implement svcSetThreadPriority.
-rw-r--r--src/core/hle/svc.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 4323c1a29..fdd90196b 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -10,6 +10,7 @@
10#include "core/hle/kernel/client_session.h" 10#include "core/hle/kernel/client_session.h"
11#include "core/hle/kernel/handle_table.h" 11#include "core/hle/kernel/handle_table.h"
12#include "core/hle/kernel/process.h" 12#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/resource_limit.h"
13#include "core/hle/kernel/sync_object.h" 14#include "core/hle/kernel/sync_object.h"
14#include "core/hle/kernel/thread.h" 15#include "core/hle/kernel/thread.h"
15#include "core/hle/lock.h" 16#include "core/hle/lock.h"
@@ -155,6 +156,34 @@ static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) {
155 return RESULT_SUCCESS; 156 return RESULT_SUCCESS;
156} 157}
157 158
159/// Sets the priority for the specified thread
160static ResultCode SetThreadPriority(Handle handle, u32 priority) {
161 if (priority > THREADPRIO_LOWEST) {
162 return Kernel::ERR_OUT_OF_RANGE;
163 }
164
165 SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
166 if (!thread)
167 return Kernel::ERR_INVALID_HANDLE;
168
169 // Note: The kernel uses the current process's resource limit instead of
170 // the one from the thread owner's resource limit.
171 SharedPtr<Kernel::ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
172 if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
173 return Kernel::ERR_NOT_AUTHORIZED;
174 }
175
176 thread->SetPriority(priority);
177 thread->UpdatePriority();
178
179 // Update the mutexes that this thread is waiting for
180 for (auto& mutex : thread->pending_mutexes)
181 mutex->UpdatePriority();
182
183 Core::System::GetInstance().PrepareReschedule();
184 return RESULT_SUCCESS;
185}
186
158/// Query process memory 187/// Query process memory
159static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/, 188static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_info*/,
160 Kernel::Handle process_handle, u64 addr) { 189 Kernel::Handle process_handle, u64 addr) {
@@ -257,7 +286,7 @@ static const FunctionDef SVC_Table[] = {
257 {0x0A, nullptr, "svcExitThread"}, 286 {0x0A, nullptr, "svcExitThread"},
258 {0x0B, HLE::Wrap<SleepThread>, "svcSleepThread"}, 287 {0x0B, HLE::Wrap<SleepThread>, "svcSleepThread"},
259 {0x0C, HLE::Wrap<GetThreadPriority>, "svcGetThreadPriority"}, 288 {0x0C, HLE::Wrap<GetThreadPriority>, "svcGetThreadPriority"},
260 {0x0D, nullptr, "svcSetThreadPriority"}, 289 {0x0D, HLE::Wrap<SetThreadPriority>, "svcSetThreadPriority"},
261 {0x0E, nullptr, "svcGetThreadCoreMask"}, 290 {0x0E, nullptr, "svcGetThreadCoreMask"},
262 {0x0F, nullptr, "svcSetThreadCoreMask"}, 291 {0x0F, nullptr, "svcSetThreadCoreMask"},
263 {0x10, nullptr, "svcGetCurrentProcessorNumber"}, 292 {0x10, nullptr, "svcGetCurrentProcessorNumber"},