mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Kernel: Protect PTYMultiplexer freelist with spinlock instead of mutex
This commit is contained in:
parent
6fbb924bbf
commit
0899153170
2 changed files with 4 additions and 5 deletions
|
@ -24,7 +24,7 @@ PTYMultiplexer& PTYMultiplexer::the()
|
|||
UNMAP_AFTER_INIT PTYMultiplexer::PTYMultiplexer()
|
||||
: CharacterDevice(5, 2)
|
||||
{
|
||||
m_freelist.with_exclusive([&](auto& freelist) {
|
||||
m_freelist.with([&](auto& freelist) {
|
||||
freelist.ensure_capacity(max_pty_pairs);
|
||||
for (int i = max_pty_pairs; i > 0; --i)
|
||||
freelist.unchecked_append(i - 1);
|
||||
|
@ -42,7 +42,7 @@ UNMAP_AFTER_INIT void PTYMultiplexer::initialize()
|
|||
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> PTYMultiplexer::open(int options)
|
||||
{
|
||||
return m_freelist.with_exclusive([&](auto& freelist) -> ErrorOr<NonnullRefPtr<OpenFileDescription>> {
|
||||
return m_freelist.with([&](auto& freelist) -> ErrorOr<NonnullRefPtr<OpenFileDescription>> {
|
||||
if (freelist.is_empty())
|
||||
return EBUSY;
|
||||
|
||||
|
@ -58,7 +58,7 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> PTYMultiplexer::open(int options)
|
|||
|
||||
void PTYMultiplexer::notify_master_destroyed(Badge<MasterPTY>, unsigned index)
|
||||
{
|
||||
m_freelist.with_exclusive([&](auto& freelist) {
|
||||
m_freelist.with([&](auto& freelist) {
|
||||
freelist.append(index);
|
||||
dbgln_if(PTMX_DEBUG, "PTYMultiplexer: {} added to freelist", index);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <AK/Badge.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -36,7 +35,7 @@ private:
|
|||
virtual StringView class_name() const override { return "PTYMultiplexer"sv; }
|
||||
|
||||
static constexpr size_t max_pty_pairs = 64;
|
||||
MutexProtected<Vector<unsigned, max_pty_pairs>> m_freelist;
|
||||
SpinlockProtected<Vector<unsigned, max_pty_pairs>> m_freelist;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue