diff options
| author | 2015-03-23 23:55:21 -0400 | |
|---|---|---|
| committer | 2015-04-09 19:05:21 -0400 | |
| commit | 7b9f428b23e1761e7b6c177d2e8eb9219ac6b7f6 (patch) | |
| tree | 597dff81a4b2935daaa7890c932b00cea4d6ae53 /src/core/hle/svc.cpp | |
| parent | SVC: Reschedule on svcCreateThread. (diff) | |
| download | yuzu-7b9f428b23e1761e7b6c177d2e8eb9219ac6b7f6.tar.gz yuzu-7b9f428b23e1761e7b6c177d2e8eb9219ac6b7f6.tar.xz yuzu-7b9f428b23e1761e7b6c177d2e8eb9219ac6b7f6.zip | |
Thread: Implement priority boost for starved threads.
SVC: Return correct error code on invalid CreateThread processor ID.
SVC: Assert when creating a thread with an invalid userland priority.
Diffstat (limited to 'src/core/hle/svc.cpp')
| -rw-r--r-- | src/core/hle/svc.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index e89e97238..82e187466 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -312,7 +312,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | /// Creates a new thread | 314 | /// Creates a new thread |
| 315 | static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) { | 315 | static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) { |
| 316 | using Kernel::Thread; | 316 | using Kernel::Thread; |
| 317 | 317 | ||
| 318 | std::string name; | 318 | std::string name; |
| @@ -323,6 +323,21 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u | |||
| 323 | name = Common::StringFromFormat("unknown-%08x", entry_point); | 323 | name = Common::StringFromFormat("unknown-%08x", entry_point); |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | // TODO(bunnei): Implement resource limits to return an error code instead of the below assert. | ||
| 327 | // The error code should be: Description::NotAuthorized, Module::OS, Summary::WrongArgument, | ||
| 328 | // Level::Permanent | ||
| 329 | ASSERT_MSG(priority >= THREADPRIO_USERLAND_MAX, "Unexpected thread priority!"); | ||
| 330 | |||
| 331 | if (priority > THREADPRIO_LOWEST) { | ||
| 332 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, | ||
| 333 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 334 | } | ||
| 335 | |||
| 336 | if (processor_id > THREADPROCESSORID_MAX) { | ||
| 337 | return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel, | ||
| 338 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | ||
| 339 | } | ||
| 340 | |||
| 326 | CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create( | 341 | CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create( |
| 327 | name, entry_point, priority, arg, processor_id, stack_top)); | 342 | name, entry_point, priority, arg, processor_id, stack_top)); |
| 328 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread))); | 343 | CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(thread))); |
| @@ -331,11 +346,6 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u | |||
| 331 | "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, | 346 | "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, |
| 332 | name.c_str(), arg, stack_top, priority, processor_id, *out_handle); | 347 | name.c_str(), arg, stack_top, priority, processor_id, *out_handle); |
| 333 | 348 | ||
| 334 | if (THREADPROCESSORID_1 == processor_id) { | ||
| 335 | LOG_WARNING(Kernel_SVC, | ||
| 336 | "thread designated for system CPU core (UNIMPLEMENTED) will be run with app core scheduling"); | ||
| 337 | } | ||
| 338 | |||
| 339 | HLE::Reschedule(__func__); | 349 | HLE::Reschedule(__func__); |
| 340 | 350 | ||
| 341 | return RESULT_SUCCESS; | 351 | return RESULT_SUCCESS; |