mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	Address review comments
This commit is contained in:
		
							parent
							
								
									ca3d9d659e
								
							
						
					
					
						commit
						3ee9f669c1
					
				
					 7 changed files with 29 additions and 28 deletions
				
			
		|  | @ -41,7 +41,8 @@ SharedPtr<Thread> AddressArbiter::ResumeHighestPriorityThread(VAddr address) { | |||
|     // Determine which threads are waiting on this address, those should be considered for wakeup.
 | ||||
|     auto matches_start = std::stable_partition( | ||||
|         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; | ||||
|         }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -109,7 +109,7 @@ void Mutex::UpdatePriority() { | |||
|     if (!holding_thread) | ||||
|         return; | ||||
| 
 | ||||
|     u32 best_priority = THREADPRIO_LOWEST; | ||||
|     u32 best_priority = ThreadPrioLowest; | ||||
|     for (auto& waiter : GetWaitingThreads()) { | ||||
|         if (waiter->current_priority < best_priority) | ||||
|             best_priority = waiter->current_priority; | ||||
|  |  | |||
|  | @ -725,7 +725,7 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point | |||
|                                u32 stack_top, s32 processor_id) { | ||||
|     std::string name = fmt::format("thread-{:08X}", entry_point); | ||||
| 
 | ||||
|     if (priority > THREADPRIO_LOWEST) { | ||||
|     if (priority > ThreadPrioLowest) { | ||||
|         return ERR_OUT_OF_RANGE; | ||||
|     } | ||||
| 
 | ||||
|  | @ -734,20 +734,20 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point | |||
|         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.
 | ||||
|         processor_id = g_current_process->ideal_processor; | ||||
|         ASSERT(processor_id != THREADPROCESSORID_DEFAULT); | ||||
|         ASSERT(processor_id != ThreadProcessorIdDefault); | ||||
|     } | ||||
| 
 | ||||
|     switch (processor_id) { | ||||
|     case THREADPROCESSORID_0: | ||||
|     case ThreadProcessorId0: | ||||
|         break; | ||||
|     case THREADPROCESSORID_ALL: | ||||
|     case ThreadProcessorIdAll: | ||||
|         LOG_INFO(Kernel_SVC, | ||||
|                  "Newly created thread is allowed to be run in any Core, unimplemented."); | ||||
|         break; | ||||
|     case THREADPROCESSORID_1: | ||||
|     case ThreadProcessorId1: | ||||
|         LOG_ERROR(Kernel_SVC, | ||||
|                   "Newly created thread must run in the SysCore (Core1), unimplemented."); | ||||
|         break; | ||||
|  | @ -796,7 +796,7 @@ static ResultCode GetThreadPriority(u32* priority, Handle handle) { | |||
| 
 | ||||
| /// Sets the priority for the specified thread
 | ||||
| static ResultCode SetThreadPriority(Handle handle, u32 priority) { | ||||
|     if (priority > THREADPRIO_LOWEST) { | ||||
|     if (priority > ThreadPrioLowest) { | ||||
|         return ERR_OUT_OF_RANGE; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -45,7 +45,7 @@ static Kernel::HandleTable wakeup_callback_handle_table; | |||
| static std::vector<SharedPtr<Thread>> thread_list; | ||||
| 
 | ||||
| // 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; | ||||
| 
 | ||||
|  | @ -324,12 +324,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
|                                             u32 arg, s32 processor_id, VAddr stack_top, | ||||
|                                             SharedPtr<Process> owner_process) { | ||||
|     // 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); | ||||
|         return ERR_OUT_OF_RANGE; | ||||
|     } | ||||
| 
 | ||||
|     if (processor_id > THREADPROCESSORID_MAX) { | ||||
|     if (processor_id > ThreadProcessorIdMax) { | ||||
|         LOG_ERROR(Kernel_SVC, "Invalid processor id: {}", processor_id); | ||||
|         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) { | ||||
|     ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, | ||||
|     ASSERT_MSG(priority <= ThreadPrioLowest && priority >= ThreadPrioHighest, | ||||
|                "Invalid priority value."); | ||||
|     // If thread was ready, adjust queues
 | ||||
|     if (status == ThreadStatus::Ready) | ||||
|  |  | |||
|  | @ -21,21 +21,21 @@ class Mutex; | |||
| class Process; | ||||
| 
 | ||||
| enum ThreadPriority : u32 { | ||||
|     THREADPRIO_HIGHEST = 0,       ///< Highest thread priority
 | ||||
|     THREADPRIO_USERLAND_MAX = 24, ///< Highest thread priority for userland apps
 | ||||
|     THREADPRIO_DEFAULT = 48,      ///< Default thread priority for userland apps
 | ||||
|     THREADPRIO_LOWEST = 63,       ///< Lowest thread priority
 | ||||
|     ThreadPrioHighest = 0,      ///< Highest thread priority
 | ||||
|     ThreadPrioUserlandMax = 24, ///< Highest thread priority for userland apps
 | ||||
|     ThreadPrioDefault = 48,     ///< Default thread priority for userland apps
 | ||||
|     ThreadPrioLowest = 63,      ///< Lowest thread priority
 | ||||
| }; | ||||
| 
 | ||||
| enum ThreadProcessorId : s32 { | ||||
|     THREADPROCESSORID_DEFAULT = -2, ///< Run thread on default core specified by exheader
 | ||||
|     THREADPROCESSORID_ALL = -1,     ///< Run thread on either core
 | ||||
|     THREADPROCESSORID_0 = 0,        ///< Run thread on core 0 (AppCore)
 | ||||
|     THREADPROCESSORID_1 = 1,        ///< Run thread on core 1 (SysCore)
 | ||||
|     THREADPROCESSORID_MAX = 2,      ///< Processor ID must be less than this
 | ||||
|     ThreadProcessorIdDefault = -2, ///< Run thread on default core specified by exheader
 | ||||
|     ThreadProcessorIdAll = -1,     ///< Run thread on either core
 | ||||
|     ThreadProcessorId0 = 0,        ///< Run thread on core 0 (AppCore)
 | ||||
|     ThreadProcessorId1 = 1,        ///< Run thread on core 1 (SysCore)
 | ||||
|     ThreadProcessorIdMax = 2,      ///< Processor ID must be less than this
 | ||||
| }; | ||||
| 
 | ||||
| enum ThreadStatus { | ||||
| enum class ThreadStatus { | ||||
|     Running,      ///< Currently running
 | ||||
|     Ready,        ///< Ready to run
 | ||||
|     WaitArb,      ///< Waiting on an address arbiter
 | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ void WaitObject::RemoveWaitingThread(Thread* thread) { | |||
| 
 | ||||
| SharedPtr<Thread> WaitObject::GetHighestPriorityReadyThread() { | ||||
|     Thread* candidate = nullptr; | ||||
|     u32 candidate_priority = THREADPRIO_LOWEST + 1; | ||||
|     u32 candidate_priority = ThreadPrioLowest + 1; | ||||
| 
 | ||||
|     for (const auto& thread : waiting_threads) { | ||||
|         // The list of waiting threads must not contain threads that are not waiting to be awakened.
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue