kqueue
Kqueue is a scalable event notification interface introduced in FreeBSD 4.1,[1] also supported in NetBSD, OpenBSD, DragonflyBSD, and OS X. Kqueue was originally authored in 2000 by Jonathan Lemon, then involved with the FreeBSD Core Team.
Kqueue provides efficient input and output event pipelines between the kernel and userland. Thus, it is possible to modify event filters as well as receive pending events while using only a single system call to kevent(2)
per main event loop iteration. This contrasts with older traditional polling system calls such as poll(2)
and select(2)
which are less efficient, especially when polling for events on a large number of file descriptors.
Kqueue not only handles file descriptor events but is also used for various other notifications such as file modification monitoring, signals, asynchronous I/O events (AIO), child process state change monitoring and timers which support nanosecond resolution.
Some other operating systems which traditionally only supported select(2)
and poll(2)
also currently provide more efficient polling alternatives, such as epoll on Linux and I/O completion ports on Windows and Solaris.
See also
OS-independent libraries with support for kqueue:
Kqueue equivalent for other platforms:
- on Linux: epoll
- on Solaris, Windows and AIX: I/O completion ports
libkqueue
is a user space implementation of kqueue(2)
, which translates calls to an operating system's native backend event mechanism.[2]
References
External links
- Kqueue(2) man page
- FreeBSD source code of the
kqueue()
system call - OpenBSD source code of the
kqueue()
system call - NetBSD source code of the
kqueue()
system call - DragonFly BSD source code of the
kqueue()
system call