mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +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
16 changed files with 37 additions and 37 deletions
|
@ -23,16 +23,16 @@ ErrorOr<FlatPtr> Process::sys$fcntl(int fd, int cmd, u32 arg)
|
|||
int arg_fd = (int)arg;
|
||||
if (arg_fd < 0)
|
||||
return EINVAL;
|
||||
return m_fds.with([&](auto& fds) -> ErrorOr<FlatPtr> {
|
||||
return m_fds.with_exclusive([&](auto& fds) -> ErrorOr<FlatPtr> {
|
||||
auto fd_allocation = TRY(fds.allocate(arg_fd));
|
||||
fds[fd_allocation.fd].set(*description);
|
||||
return fd_allocation.fd;
|
||||
});
|
||||
}
|
||||
case F_GETFD:
|
||||
return m_fds.with([fd](auto& fds) { return fds[fd].flags(); });
|
||||
return m_fds.with_exclusive([fd](auto& fds) { return fds[fd].flags(); });
|
||||
case F_SETFD:
|
||||
m_fds.with([fd, arg](auto& fds) { fds[fd].set_flags(arg); });
|
||||
m_fds.with_exclusive([fd, arg](auto& fds) { fds[fd].set_flags(arg); });
|
||||
break;
|
||||
case F_GETFL:
|
||||
return description->file_flags();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue