mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-03 08:52:54 +00:00
Kernel: Switch process file descriptor table from spinlock to mutex
There's no reason for this to use a spinlock. Instead, let's allow threads to block if someone else is using the descriptor table.
This commit is contained in:
parent
8ebec2938c
commit
b56646e293
Notes:
sideshowbarker
2024-07-17 20:03:36 +09:00
Author: https://github.com/awesomekling
Commit: b56646e293
16 changed files with 37 additions and 37 deletions
|
@ -13,7 +13,7 @@ ErrorOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
|
|||
{
|
||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||
TRY(require_promise(Pledge::stdio));
|
||||
auto open_count = fds().with([](auto& fds) { return fds.open_count(); });
|
||||
auto open_count = fds().with_shared([](auto& fds) { return fds.open_count(); });
|
||||
if (open_count + 2 > OpenFileDescriptions::max_open())
|
||||
return EMFILE;
|
||||
// Reject flags other than O_CLOEXEC, O_NONBLOCK
|
||||
|
@ -26,7 +26,7 @@ ErrorOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
|
|||
ScopedDescriptionAllocation reader_fd_allocation;
|
||||
ScopedDescriptionAllocation writer_fd_allocation;
|
||||
|
||||
TRY(m_fds.with([&](auto& fds) -> ErrorOr<void> {
|
||||
TRY(m_fds.with_exclusive([&](auto& fds) -> ErrorOr<void> {
|
||||
reader_fd_allocation = TRY(fds.allocate());
|
||||
writer_fd_allocation = TRY(fds.allocate());
|
||||
return {};
|
||||
|
@ -42,7 +42,7 @@ ErrorOr<FlatPtr> Process::sys$pipe(int pipefd[2], int flags)
|
|||
writer_description->set_blocking(false);
|
||||
}
|
||||
|
||||
TRY(m_fds.with([&](auto& fds) -> ErrorOr<void> {
|
||||
TRY(m_fds.with_exclusive([&](auto& fds) -> ErrorOr<void> {
|
||||
fds[reader_fd_allocation.fd].set(move(reader_description), fd_flags);
|
||||
fds[writer_fd_allocation.fd].set(move(writer_description), fd_flags);
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue