Address review comments

This commit is contained in:
fearlessTobi 2018-09-21 16:39:10 +02:00
parent ca3d9d659e
commit 3ee9f669c1
7 changed files with 29 additions and 28 deletions

View file

@ -213,16 +213,16 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
QString processor; QString processor;
switch (thread.processor_id) { switch (thread.processor_id) {
case Kernel::ThreadProcessorId::THREADPROCESSORID_DEFAULT: case Kernel::ThreadProcessorId::ThreadProcessorIdDefault:
processor = tr("default"); processor = tr("default");
break; break;
case Kernel::ThreadProcessorId::THREADPROCESSORID_ALL: case Kernel::ThreadProcessorId::ThreadProcessorIdAll:
processor = tr("all"); processor = tr("all");
break; break;
case Kernel::ThreadProcessorId::THREADPROCESSORID_0: case Kernel::ThreadProcessorId::ThreadProcessorId0:
processor = tr("AppCore"); processor = tr("AppCore");
break; break;
case Kernel::ThreadProcessorId::THREADPROCESSORID_1: case Kernel::ThreadProcessorId::ThreadProcessorId1:
processor = tr("SysCore"); processor = tr("SysCore");
break; break;
default: default:

View file

@ -41,7 +41,8 @@ SharedPtr<Thread> AddressArbiter::ResumeHighestPriorityThread(VAddr address) {
// Determine which threads are waiting on this address, those should be considered for wakeup. // Determine which threads are waiting on this address, those should be considered for wakeup.
auto matches_start = std::stable_partition( auto matches_start = std::stable_partition(
waiting_threads.begin(), waiting_threads.end(), [address](const auto& thread) { waiting_threads.begin(), waiting_threads.end(), [address](const auto& thread) {
ASSERT_MSG(thread->status == ThreadStatus::WaitArb, "Inconsistent AddressArbiter state"); ASSERT_MSG(thread->status == ThreadStatus::WaitArb,
"Inconsistent AddressArbiter state");
return thread->wait_address != address; return thread->wait_address != address;
}); });

View file

@ -109,7 +109,7 @@ void Mutex::UpdatePriority() {
if (!holding_thread) if (!holding_thread)
return; return;
u32 best_priority = THREADPRIO_LOWEST; u32 best_priority = ThreadPrioLowest;
for (auto& waiter : GetWaitingThreads()) { for (auto& waiter : GetWaitingThreads()) {
if (waiter->current_priority < best_priority) if (waiter->current_priority < best_priority)
best_priority = waiter->current_priority; best_priority = waiter->current_priority;

View file

@ -725,7 +725,7 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
u32 stack_top, s32 processor_id) { u32 stack_top, s32 processor_id) {
std::string name = fmt::format("thread-{:08X}", entry_point); std::string name = fmt::format("thread-{:08X}", entry_point);
if (priority > THREADPRIO_LOWEST) { if (priority > ThreadPrioLowest) {
return ERR_OUT_OF_RANGE; return ERR_OUT_OF_RANGE;
} }
@ -734,20 +734,20 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point
return ERR_NOT_AUTHORIZED; return ERR_NOT_AUTHORIZED;
} }
if (processor_id == THREADPROCESSORID_DEFAULT) { if (processor_id == ThreadProcessorIdDefault) {
// Set the target CPU to the one specified in the process' exheader. // Set the target CPU to the one specified in the process' exheader.
processor_id = g_current_process->ideal_processor; processor_id = g_current_process->ideal_processor;
ASSERT(processor_id != THREADPROCESSORID_DEFAULT); ASSERT(processor_id != ThreadProcessorIdDefault);
} }
switch (processor_id) { switch (processor_id) {
case THREADPROCESSORID_0: case ThreadProcessorId0:
break; break;
case THREADPROCESSORID_ALL: case ThreadProcessorIdAll:
LOG_INFO(Kernel_SVC, LOG_INFO(Kernel_SVC,
"Newly created thread is allowed to be run in any Core, unimplemented."); "Newly created thread is allowed to be run in any Core, unimplemented.");
break; break;
case THREADPROCESSORID_1: case ThreadProcessorId1:
LOG_ERROR(Kernel_SVC, LOG_ERROR(Kernel_SVC,
"Newly created thread must run in the SysCore (Core1), unimplemented."); "Newly created thread must run in the SysCore (Core1), unimplemented.");
break; break;
@ -796,7 +796,7 @@ static ResultCode GetThreadPriority(u32* priority, Handle handle) {
/// Sets the priority for the specified thread /// Sets the priority for the specified thread
static ResultCode SetThreadPriority(Handle handle, u32 priority) { static ResultCode SetThreadPriority(Handle handle, u32 priority) {
if (priority > THREADPRIO_LOWEST) { if (priority > ThreadPrioLowest) {
return ERR_OUT_OF_RANGE; return ERR_OUT_OF_RANGE;
} }

View file

@ -45,7 +45,7 @@ static Kernel::HandleTable wakeup_callback_handle_table;
static std::vector<SharedPtr<Thread>> thread_list; static std::vector<SharedPtr<Thread>> thread_list;
// Lists only ready thread ids. // Lists only ready thread ids.
static Common::ThreadQueueList<Thread*, THREADPRIO_LOWEST + 1> ready_queue; static Common::ThreadQueueList<Thread*, ThreadPrioLowest + 1> ready_queue;
static SharedPtr<Thread> current_thread; static SharedPtr<Thread> current_thread;
@ -324,12 +324,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
u32 arg, s32 processor_id, VAddr stack_top, u32 arg, s32 processor_id, VAddr stack_top,
SharedPtr<Process> owner_process) { SharedPtr<Process> owner_process) {
// Check if priority is in ranged. Lowest priority -> highest priority id. // Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > THREADPRIO_LOWEST) { if (priority > ThreadPrioLowest) {
LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority);
return ERR_OUT_OF_RANGE; return ERR_OUT_OF_RANGE;
} }
if (processor_id > THREADPROCESSORID_MAX) { if (processor_id > ThreadProcessorIdMax) {
LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id); LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id);
return ERR_OUT_OF_RANGE_KERNEL; return ERR_OUT_OF_RANGE_KERNEL;
} }
@ -414,7 +414,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
} }
void Thread::SetPriority(u32 priority) { void Thread::SetPriority(u32 priority) {
ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, ASSERT_MSG(priority <= ThreadPrioLowest && priority >= ThreadPrioHighest,
"Invalid priority value."); "Invalid priority value.");
// If thread was ready, adjust queues // If thread was ready, adjust queues
if (status == ThreadStatus::Ready) if (status == ThreadStatus::Ready)

View file

@ -21,21 +21,21 @@ class Mutex;
class Process; class Process;
enum ThreadPriority : u32 { enum ThreadPriority : u32 {
THREADPRIO_HIGHEST = 0, ///< Highest thread priority ThreadPrioHighest = 0, ///< Highest thread priority
THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps ThreadPrioUserlandMax = 24, ///< Highest thread priority for userland apps
THREADPRIO_DEFAULT = 48, ///< Default thread priority for userland apps ThreadPrioDefault = 48, ///< Default thread priority for userland apps
THREADPRIO_LOWEST = 63, ///< Lowest thread priority ThreadPrioLowest = 63, ///< Lowest thread priority
}; };
enum ThreadProcessorId : s32 { enum ThreadProcessorId : s32 {
THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader ThreadProcessorIdDefault = -2, ///< Run thread on default core specified by exheader
THREADPROCESSORID_ALL = -1, ///< Run thread on either core ThreadProcessorIdAll = -1, ///< Run thread on either core
THREADPROCESSORID_0 = 0, ///< Run thread on core 0 (AppCore) ThreadProcessorId0 = 0, ///< Run thread on core 0 (AppCore)
THREADPROCESSORID_1 = 1, ///< Run thread on core 1 (SysCore) ThreadProcessorId1 = 1, ///< Run thread on core 1 (SysCore)
THREADPROCESSORID_MAX = 2, ///< Processor ID must be less than this ThreadProcessorIdMax = 2, ///< Processor ID must be less than this
}; };
enum ThreadStatus { enum class ThreadStatus {
Running, ///< Currently running Running, ///< Currently running
Ready, ///< Ready to run Ready, ///< Ready to run
WaitArb, ///< Waiting on an address arbiter WaitArb, ///< Waiting on an address arbiter

View file

@ -34,7 +34,7 @@ void WaitObject::RemoveWaitingThread(Thread* thread) {
SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() {
Thread* candidate = nullptr; Thread* candidate = nullptr;
u32 candidate_priority = THREADPRIO_LOWEST + 1; u32 candidate_priority = ThreadPrioLowest + 1;
for (const auto& thread : waiting_threads) { for (const auto& thread : waiting_threads) {
// The list of waiting threads must not contain threads that are not waiting to be awakened. // The list of waiting threads must not contain threads that are not waiting to be awakened.