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.
This commit is contained in:
parent
ee3377b67d
commit
7b9f428b23
5 changed files with 92 additions and 28 deletions
|
@ -312,7 +312,7 @@ static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_lim
|
|||
}
|
||||
|
||||
/// Creates a new thread
|
||||
static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 processor_id) {
|
||||
static ResultCode CreateThread(Handle* out_handle, s32 priority, u32 entry_point, u32 arg, u32 stack_top, s32 processor_id) {
|
||||
using Kernel::Thread;
|
||||
|
||||
std::string name;
|
||||
|
@ -323,6 +323,21 @@ static ResultCode CreateThread(u32* out_handle, u32 priority, u32 entry_point, u
|
|||
name = Common::StringFromFormat("unknown-%08x", entry_point);
|
||||
}
|
||||
|
||||
// TODO(bunnei): Implement resource limits to return an error code instead of the below assert.
|
||||
// The error code should be: Description::NotAuthorized, Module::OS, Summary::WrongArgument,
|
||||
// Level::Permanent
|
||||
ASSERT_MSG(priority >= THREADPRIO_USERLAND_MAX, "Unexpected thread priority!");
|
||||
|
||||
if (priority > THREADPRIO_LOWEST) {
|
||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
|
||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||
}
|
||||
|
||||
if (processor_id > THREADPROCESSORID_MAX) {
|
||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel,
|
||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
||||
}
|
||||
|
||||
CASCADE_RESULT(SharedPtr<Thread> thread, Kernel::Thread::Create(
|
||||
name, entry_point, priority, arg, processor_id, stack_top));
|
||||
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
|
|||
"threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
|
||||
name.c_str(), arg, stack_top, priority, processor_id, *out_handle);
|
||||
|
||||
if (THREADPROCESSORID_1 == processor_id) {
|
||||
LOG_WARNING(Kernel_SVC,
|
||||
"thread designated for system CPU core (UNIMPLEMENTED) will be run with app core scheduling");
|
||||
}
|
||||
|
||||
HLE::Reschedule(__func__);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue