mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:42:43 +00:00 
			
		
		
		
	Kernel: Make DoubleBuffer use a KBuffer instead of kmalloc()ing
Background: DoubleBuffer is a handy buffer class in the kernel that allows you to keep writing to it from the "outside" while the "inside" reads from it. It's used for things like LocalSocket and PTY's. Internally, it has a read buffer and a write buffer, but the two will swap places when the read buffer is exhausted (by reading from it.) Before this patch, it was internally implemented as two Vector<u8> that we would swap between when the reader side had exhausted the data in the read buffer. Now instead we preallocate a large KBuffer (64KB*2) on DoubleBuffer construction and use that throughout its lifetime. This removes all the kmalloc heap traffic caused by DoubleBuffers :^)
This commit is contained in:
		
							parent
							
								
									4027a64fc5
								
							
						
					
					
						commit
						1cca5142af
					
				
					 5 changed files with 53 additions and 34 deletions
				
			
		|  | @ -90,7 +90,7 @@ bool FIFO::can_read(FileDescription&) const | |||
| 
 | ||||
| bool FIFO::can_write(FileDescription&) const | ||||
| { | ||||
|     return m_buffer.bytes_in_write_buffer() < 4096 || !m_readers; | ||||
|     return m_buffer.space_for_writing() || !m_readers; | ||||
| } | ||||
| 
 | ||||
| ssize_t FIFO::read(FileDescription&, u8* buffer, ssize_t size) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling