mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:02:45 +00:00 
			
		
		
		
	Kernel: Only consider scheduler Running threads if they're the current
There will be as many threads in Running state as there are CPUs. Only consider a thread in that state if it is the current thread already.
This commit is contained in:
		
							parent
							
								
									1e2e3eed62
								
							
						
					
					
						commit
						3ffdaabe10
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		|  | @ -465,8 +465,8 @@ bool Scheduler::pick_next() | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
| #ifdef SCHEDULER_RUNNABLE_DEBUG | #ifdef SCHEDULER_RUNNABLE_DEBUG | ||||||
|     dbg() << "Non-runnables:"; |     dbg() << "Scheduler[" << Processor::current().id() << "]: Non-runnables:"; | ||||||
|     Scheduler::for_each_nonrunnable([](Thread& thread) -> IterationDecision { |     Scheduler::for_each_nonrunnable([&](Thread& thread) -> IterationDecision { | ||||||
|         if (thread.state() == Thread::Queued) |         if (thread.state() == Thread::Queued) | ||||||
|             dbg() << "  " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip) << " Reason: " << (thread.wait_reason() ? thread.wait_reason() : "none"); |             dbg() << "  " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip) << " Reason: " << (thread.wait_reason() ? thread.wait_reason() : "none"); | ||||||
|         else if (thread.state() == Thread::Dying) |         else if (thread.state() == Thread::Dying) | ||||||
|  | @ -476,7 +476,7 @@ bool Scheduler::pick_next() | ||||||
|         return IterationDecision::Continue; |         return IterationDecision::Continue; | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     dbg() << "Runnables:"; |     dbg() << "Scheduler[" << Processor::current().id() << "]: Runnables:"; | ||||||
|     Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision { |     Scheduler::for_each_runnable([](Thread& thread) -> IterationDecision { | ||||||
|         dbg() << "  " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip); |         dbg() << "  " << String::format("%3u", thread.effective_priority()) << "/" << String::format("%2u", thread.priority()) << " " << String::format("%-12s", thread.state_string()) << " " << thread << " @ " << String::format("%w", thread.tss().cs) << ":" << String::format("%x", thread.tss().eip); | ||||||
|         return IterationDecision::Continue; |         return IterationDecision::Continue; | ||||||
|  | @ -487,7 +487,10 @@ bool Scheduler::pick_next() | ||||||
| 
 | 
 | ||||||
|     Vector<Thread*, 128> sorted_runnables; |     Vector<Thread*, 128> sorted_runnables; | ||||||
|     for_each_runnable([&](auto& thread) { |     for_each_runnable([&](auto& thread) { | ||||||
|         if ((thread.affinity() & (1u << Processor::current().id())) != 0) |         if ((thread.affinity() & (1u << Processor::current().id())) == 0) | ||||||
|  |             return IterationDecision::Continue; | ||||||
|  |         if (thread.state() == Thread::Running && &thread != current_thread) | ||||||
|  |             return IterationDecision::Continue; | ||||||
|         sorted_runnables.append(&thread); |         sorted_runnables.append(&thread); | ||||||
|         if (&thread == scheduler_data.m_pending_beneficiary) { |         if (&thread == scheduler_data.m_pending_beneficiary) { | ||||||
|             thread_to_schedule = &thread; |             thread_to_schedule = &thread; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Tom
						Tom