kern: fix bug in SvcSetThreadPriority

This commit is contained in:
Michael Scire 2020-07-20 02:11:49 -07:00 committed by SciresM
parent 94f9cc1626
commit 5b8a20dbf7
3 changed files with 17 additions and 1 deletions

View File

@ -347,8 +347,10 @@ namespace ams::kern {
constexpr s32 GetIdealCore() const { return this->ideal_core_id; } constexpr s32 GetIdealCore() const { return this->ideal_core_id; }
constexpr s32 GetActiveCore() const { return this->core_id; } constexpr s32 GetActiveCore() const { return this->core_id; }
constexpr void SetActiveCore(s32 core) { this->core_id = core; } constexpr void SetActiveCore(s32 core) { this->core_id = core; }
constexpr s32 GetPriority() const { return this->priority; } constexpr s32 GetPriority() const { return this->priority; }
constexpr void SetPriority(s32 prio) { this->priority = prio; } constexpr void SetPriority(s32 prio) { this->priority = prio; }
constexpr s32 GetBasePriority() const { return this->base_priority; } constexpr s32 GetBasePriority() const { return this->base_priority; }
constexpr QueueEntry &GetPriorityQueueEntry(s32 core) { return this->per_core_priority_queue_entry[core]; } constexpr QueueEntry &GetPriorityQueueEntry(s32 core) { return this->per_core_priority_queue_entry[core]; }
@ -438,6 +440,7 @@ namespace ams::kern {
void Wakeup(); void Wakeup();
void SetBasePriority(s32 priority);
Result SetPriorityToIdle(); Result SetPriorityToIdle();
Result Run(); Result Run();

View File

@ -384,6 +384,19 @@ namespace ams::kern {
} }
} }
void KThread::SetBasePriority(s32 priority) {
MESOSPHERE_ASSERT_THIS();
MESOSPHERE_ASSERT(ams::svc::HighestThreadPriority <= priority && priority <= ams::svc::LowestThreadPriority);
KScopedSchedulerLock sl;
/* Change our base priority. */
this->base_priority = priority;
/* Perform a priority restoration. */
RestorePriority(this);
}
Result KThread::SetPriorityToIdle() { Result KThread::SetPriorityToIdle() {
MESOSPHERE_ASSERT_THIS(); MESOSPHERE_ASSERT_THIS();

View File

@ -141,7 +141,7 @@ namespace ams::kern::svc {
R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle()); R_UNLESS(thread.IsNotNull(), svc::ResultInvalidHandle());
/* Set the thread priority. */ /* Set the thread priority. */
thread->SetPriority(priority); thread->SetBasePriority(priority);
return ResultSuccess(); return ResultSuccess();
} }