diff options
| author | 2017-01-12 10:14:30 -0500 | |
|---|---|---|
| committer | 2017-01-12 10:14:30 -0500 | |
| commit | 7ddfd3054dc67fa727ec7c7267f27a438ac37dc3 (patch) | |
| tree | 30bd821242a3f3dad780595673c3d5adf92ebe86 /src/core/hle/kernel/thread.cpp | |
| parent | Merge pull request #2308 from mailwl/ac-i (diff) | |
| parent | Threads: Check the process' resource limit for the max allowed priority when ... (diff) | |
| download | yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.gz yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.xz yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.zip | |
Merge pull request #2425 from Subv/cleanup_todos
Implement some TODOs in the code.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 8c6fbcd04..3b7555d87 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -353,14 +353,8 @@ static void ResetThreadContext(ARM_Interface::ThreadContext& context, u32 stack_ | |||
| 353 | 353 | ||
| 354 | ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, | 354 | ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, |
| 355 | u32 arg, s32 processor_id, VAddr stack_top) { | 355 | u32 arg, s32 processor_id, VAddr stack_top) { |
| 356 | if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) { | 356 | ASSERT_MSG(priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST, |
| 357 | s32 new_priority = MathUtil::Clamp<s32>(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); | 357 | "Invalid thread priority"); |
| 358 | LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", name.c_str(), | ||
| 359 | priority, new_priority); | ||
| 360 | // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm | ||
| 361 | // validity of this | ||
| 362 | priority = new_priority; | ||
| 363 | } | ||
| 364 | 358 | ||
| 365 | if (!Memory::IsValidVirtualAddress(entry_point)) { | 359 | if (!Memory::IsValidVirtualAddress(entry_point)) { |
| 366 | LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); | 360 | LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); |
| @@ -444,25 +438,9 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 444 | return MakeResult<SharedPtr<Thread>>(std::move(thread)); | 438 | return MakeResult<SharedPtr<Thread>>(std::move(thread)); |
| 445 | } | 439 | } |
| 446 | 440 | ||
| 447 | // TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be | ||
| 448 | // returned. | ||
| 449 | static void ClampPriority(const Thread* thread, s32* priority) { | ||
| 450 | if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) { | ||
| 451 | DEBUG_ASSERT_MSG( | ||
| 452 | false, "Application passed an out of range priority. An error should be returned."); | ||
| 453 | |||
| 454 | s32 new_priority = MathUtil::Clamp<s32>(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); | ||
| 455 | LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", | ||
| 456 | thread->name.c_str(), *priority, new_priority); | ||
| 457 | // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm | ||
| 458 | // validity of this | ||
| 459 | *priority = new_priority; | ||
| 460 | } | ||
| 461 | } | ||
| 462 | |||
| 463 | void Thread::SetPriority(s32 priority) { | 441 | void Thread::SetPriority(s32 priority) { |
| 464 | ClampPriority(this, &priority); | 442 | ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, |
| 465 | 443 | "Invalid priority value."); | |
| 466 | // If thread was ready, adjust queues | 444 | // If thread was ready, adjust queues |
| 467 | if (status == THREADSTATUS_READY) | 445 | if (status == THREADSTATUS_READY) |
| 468 | ready_queue.move(this, current_priority, priority); | 446 | ready_queue.move(this, current_priority, priority); |