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/TTY/MasterPTY.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/TTY/MasterPTY.cpp')
-rw-r--r-- | Kernel/TTY/MasterPTY.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index a3caf1b17b..5afeec5355 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -81,7 +81,7 @@ bool MasterPTY::can_write_from_slave() const { if (m_closed) return true; - return m_buffer.bytes_in_write_buffer() < 4096; + return m_buffer.space_for_writing(); } void MasterPTY::close() |