Kernel Queues and Events

Kernel Queues ('kqueue') are a stateful method of event notification. Instead of passing events to monitor with each select(2) or poll(2) system call, the program registers events to receive event notifications for. The registered events can include a pointer to user data. The kernel queues triggered events and returns them when polled for. Kernel Queues currently supports event monitors ('filters') for file descriptors, processes, signals, asynchronous I/O, and VNODEs. This interface is available in FreeBSD 5-CURRENT and 4.0-STABLE and will be in the upcoming 4.1-RELEASE.

Jonathan Lemon <jlemon@freebsd.org> of the FreeBSD project implemented Kernel Queues. The man page explains the kqueue API.

Currently, only a few programs make use of kqueue as the code hasn't been in a full FreeBSD release. Once kqueue is widely available, developers will migrate their programs to kqueue. Hopefully, other projects, like the other BSD systems, will integrate kqueue to provide a common events API.

Current kqueue developments: