mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:12:45 +00:00 
			
		
		
		
	Kernel: Refactor scheduler to use dynamic thread priorities
Threads now have numeric priorities with a base priority in the 1-99
range.
Whenever a runnable thread is *not* scheduled, its effective priority
is incremented by 1. This is tracked in Thread::m_extra_priority.
The effective priority of a thread is m_priority + m_extra_priority.
When a runnable thread *is* scheduled, its m_extra_priority is reset to
zero and the effective priority returns to base.
This means that lower-priority threads will always eventually get
scheduled to run, once its effective priority becomes high enough to
exceed the base priority of threads "above" it.
The previous values for ThreadPriority (Low, Normal and High) are now
replaced as follows:
    Low -> 10
    Normal -> 30
    High -> 50
In other words, it will take 20 ticks for a "Low" priority thread to
get to "Normal" effective priority, and another 20 to reach "High".
This is not perfect, and I've used some quite naive data structures,
but I think the mechanism will allow us to build various new and
interesting optimizations, and we can figure out better data structures
later on. :^)
			
			
This commit is contained in:
		
							parent
							
								
									816d3e6208
								
							
						
					
					
						commit
						50677bf806
					
				
					 16 changed files with 109 additions and 149 deletions
				
			
		|  | @ -25,6 +25,7 @@ public: | |||
|         CPU, | ||||
|         State, | ||||
|         Priority, | ||||
|         EffectivePriority, | ||||
|         User, | ||||
|         PID, | ||||
|         TID, | ||||
|  | @ -71,7 +72,8 @@ private: | |||
|         String name; | ||||
|         String state; | ||||
|         String user; | ||||
|         String priority; | ||||
|         u32 priority; | ||||
|         u32 effective_priority; | ||||
|         size_t amount_virtual; | ||||
|         size_t amount_resident; | ||||
|         size_t amount_dirty_private; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling