mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	Kernel: Minor Lock optimization
This commit is contained in:
		
							parent
							
								
									b4c9e85056
								
							
						
					
					
						commit
						66f46d03e4
					
				
					 1 changed files with 2 additions and 4 deletions
				
			
		|  | @ -52,8 +52,7 @@ void Lock::lock(Mode mode) | |||
|     } | ||||
|     auto current_thread = Thread::current(); | ||||
|     for (;;) { | ||||
|         bool expected = false; | ||||
|         if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) { | ||||
|         if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) { | ||||
|             do { | ||||
|                 // FIXME: Do not add new readers if writers are queued.
 | ||||
|                 bool modes_dont_conflict = !modes_conflict(m_mode, mode); | ||||
|  | @ -91,8 +90,7 @@ void Lock::unlock() | |||
| { | ||||
|     auto current_thread = Thread::current(); | ||||
|     for (;;) { | ||||
|         bool expected = false; | ||||
|         if (m_lock.compare_exchange_strong(expected, true, AK::memory_order_acq_rel)) { | ||||
|         if (m_lock.exchange(true, AK::memory_order_acq_rel) == false) { | ||||
|             ASSERT(m_times_locked); | ||||
|             --m_times_locked; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Tom
						Tom