diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-10-18 14:55:04 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-18 14:55:04 +0200 |
commit | 1cca5142afbd76833deedfdb238230ac53424855 (patch) | |
tree | f7efa21ad7fd5e0fd9cb5bc5bf0e9e66d3afa924 /Kernel/FileSystem/FIFO.cpp | |
parent | 4027a64fc59253c85ca3da358fa85f15942480c0 (diff) | |
download | serenity-1cca5142afbd76833deedfdb238230ac53424855.zip |
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 :^)
Diffstat (limited to 'Kernel/FileSystem/FIFO.cpp')
-rw-r--r-- | Kernel/FileSystem/FIFO.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 6fc77a7b2b..1e2982f519 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -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) |