Kernel/LibC: Implement basic epoll

This implementation is on top of inodes instead of fds as linux does it.
If I start finding ports/software that relies on epoll allowing
duplicate inodes, I will do what linux does.

I'm probably missing multiple epoll_notify's which may cause hangs but
the system seems to work fine :dd:
This commit is contained in:
2025-05-13 10:10:35 +03:00
parent 143a00626b
commit 1bcd1edbf5
43 changed files with 627 additions and 119 deletions

View File

@@ -3,7 +3,7 @@
#include <kernel/Thread.h>
#include <kernel/Timer/Timer.h>
#include <kernel/Process.h>
#include <sys/epoll.h>
namespace Kernel
{
@@ -36,8 +36,10 @@ namespace Kernel
{
auto old_writing_count = m_writing_count.fetch_sub(1);
ASSERT(old_writing_count > 0);
if (old_writing_count == 1)
m_thread_blocker.unblock();
if (old_writing_count != 1)
return;
epoll_notify(EPOLLHUP);
m_thread_blocker.unblock();
}
BAN::ErrorOr<size_t> Pipe::read_impl(off_t, BAN::ByteSpan buffer)
@@ -69,6 +71,8 @@ namespace Kernel
m_atime = SystemTimer::get().real_time();
epoll_notify(EPOLLOUT);
m_thread_blocker.unblock();
return to_copy;
@@ -103,6 +107,8 @@ namespace Kernel
m_mtime = current_time;
m_ctime = current_time;
epoll_notify(EPOLLIN);
m_thread_blocker.unblock();
return to_copy;