mirror of
				https://git.zaroz.cloud/nintendo-back-up/yuzu/yuzu.git
				synced 2025-05-12 00:45:25 +00:00 
			
		
		
		
	Threads: Implemented a sequential thread id
This commit is contained in:
		
							parent
							
								
									029ff9f1fd
								
							
						
					
					
						commit
						ef1d5cda06
					
				@ -78,6 +78,17 @@ static Common::ThreadQueueList<Handle> thread_ready_queue;
 | 
				
			|||||||
static Handle current_thread_handle;
 | 
					static Handle current_thread_handle;
 | 
				
			||||||
static Thread* current_thread;
 | 
					static Thread* current_thread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const u32 INITIAL_THREAD_ID = 1; ///< The first available thread id at startup
 | 
				
			||||||
 | 
					static u32 next_thread_id; ///< The next available thread id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Gets the next available thread id and increments it
 | 
				
			||||||
 | 
					 * @return Next available thread id
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static u32 NextThreadId() {
 | 
				
			||||||
 | 
					    return next_thread_id++;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Gets the current thread
 | 
					/// Gets the current thread
 | 
				
			||||||
inline Thread* GetCurrentThread() {
 | 
					inline Thread* GetCurrentThread() {
 | 
				
			||||||
    return current_thread;
 | 
					    return current_thread;
 | 
				
			||||||
@ -327,9 +338,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
 | 
				
			|||||||
    thread_queue.push_back(handle);
 | 
					    thread_queue.push_back(handle);
 | 
				
			||||||
    thread_ready_queue.prepare(priority);
 | 
					    thread_ready_queue.prepare(priority);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO(Subv): Assign valid ids to each thread, they are much lower than handle values
 | 
					    thread->thread_id = NextThreadId();
 | 
				
			||||||
    // they appear to begin at 276 and continue from there
 | 
					 | 
				
			||||||
    thread->thread_id = handle; 
 | 
					 | 
				
			||||||
    thread->status = THREADSTATUS_DORMANT;
 | 
					    thread->status = THREADSTATUS_DORMANT;
 | 
				
			||||||
    thread->entry_point = entry_point;
 | 
					    thread->entry_point = entry_point;
 | 
				
			||||||
    thread->stack_top = stack_top;
 | 
					    thread->stack_top = stack_top;
 | 
				
			||||||
@ -484,6 +493,7 @@ ResultCode GetThreadId(u32* thread_id, Handle handle) {
 | 
				
			|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ThreadingInit() {
 | 
					void ThreadingInit() {
 | 
				
			||||||
 | 
					    next_thread_id = INITIAL_THREAD_ID;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ThreadingShutdown() {
 | 
					void ThreadingShutdown() {
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,12 @@ void Reschedule();
 | 
				
			|||||||
/// Stops the current thread
 | 
					/// Stops the current thread
 | 
				
			||||||
ResultCode StopThread(Handle thread, const char* reason);
 | 
					ResultCode StopThread(Handle thread, const char* reason);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Retrieves the thread id of the specified thread handle
 | 
					/**
 | 
				
			||||||
 | 
					 * Retrieves the ID of the specified thread handle
 | 
				
			||||||
 | 
					 * @param thread_id Will contain the output thread id
 | 
				
			||||||
 | 
					 * @param handle Handle to the thread we want
 | 
				
			||||||
 | 
					 * @return Whether the function was successful or not
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
ResultCode GetThreadId(u32* thread_id, Handle handle);
 | 
					ResultCode GetThreadId(u32* thread_id, Handle handle);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Resumes a thread from waiting by marking it as "ready"
 | 
					/// Resumes a thread from waiting by marking it as "ready"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user