⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module eventfd

Module eventfd 

Source
Expand description

eventfd – Event notification file descriptor

Provides a file descriptor for event wait/notify, commonly used by epoll-based event loops (Qt6, glib). Supports both counter and semaphore semantics.

§Syscall Interface

  • eventfd_create(initval, flags) -> fd (syscall 330)
  • Read/write via standard read(2) / write(2) on returned fd

§Semantics

  • write: Adds the 8-byte unsigned integer to the internal counter. Blocks (or returns EAGAIN) if the counter would overflow u64::MAX - 1.
  • read: Returns the current counter as an 8-byte unsigned integer and resets it to zero. In semaphore mode, returns 1 and decrements by 1. Blocks (or returns EAGAIN) if the counter is zero.

Structs§

EventFdNode
VfsNode wrapper around an eventfd instance.

Constants§

EFD_CLOEXEC
EFD_CLOEXEC flag: set close-on-exec (tracked but not enforced in kernel).
EFD_NONBLOCK
EFD_NONBLOCK flag: reads/writes return EAGAIN instead of blocking.
EFD_SEMAPHORE
EFD_SEMAPHORE flag: read returns 1 and decrements (instead of draining).

Functions§

eventfd_close
Close (destroy) an eventfd instance.
eventfd_create
Create a new eventfd.
eventfd_read
Read from an eventfd. Returns the counter value as a u64.
eventfd_write
Write to an eventfd. Adds value to the internal counter.
is_readable
Query whether an eventfd is readable (counter > 0). Used by epoll to check readiness without consuming data.
is_writable
Query whether an eventfd is writable (counter < u64::MAX - 1).