Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

kqueue

From Wikipedia, the free encyclopedia
Kernel event notification mechanism for BSD operating systems

Kqueue is a scalable event notification interface introduced inFreeBSD 4.1 in July 2000,[1][2] also supported inNetBSD,OpenBSD,DragonFly BSD, andmacOS. Kqueue was originally authored in 2000 by Jonathan Lemon,[1][2] then involved with theFreeBSD Core Team. Kqueue makes it possible for software likenginx to solve thec10k problem.[3][4] The term "kqueue" refers to its function as a "kernel event queue"[1][2]

Kqueue provides efficient input and output event pipelines between thekernel anduserland. Thus, it is possible to modify event filters as well as receive pending events while using only a singlesystem call tokevent(2) per mainevent loop iteration. This contrasts with older traditionalpolling system calls such aspoll(2) andselect(2) which are less efficient, especially when polling for events on numerous file descriptors.

Kqueue not only handlesfile descriptor events but is also used for various other notifications such asfile modification monitoring,signals,asynchronous I/O events (AIO),child process state change monitoring, andtimers which supportnanosecond resolution. Furthermore, kqueue provides a way to use user-defined events in addition to the ones provided by the kernel.

Some otheroperating systems which traditionally only supportedselect(2) andpoll(2) also currently provide more efficient polling alternatives, such asepoll onLinux andI/O completion ports onWindows andSolaris.

libkqueue is auser space implementation ofkqueue(2), which translates calls to an operating system's native backend event mechanism.[5]

API

[edit]
icon
This sectionrelies largely or entirely on asingle source. Relevant discussion may be found on thetalk page. Please helpimprove this article by introducingcitations to additional sources at this section. Unsourced material may be challenged and removed.
Find sources: "Kqueue" – news ·newspapers ·books ·scholar ·JSTOR
(April 2024) (Learn how and when to remove this message)

The function prototypes and types are found in<sys/event.h>.[6]

intkqueue(void);

Creates a new kernel event queue and returns a descriptor.

intkevent(intkq,conststructkevent*changelist,intnchanges,structkevent*eventlist,intnevents,conststructtimespec*timeout);

Used to register events with the queue, then wait for and return any pending events to the user. In contrast toepoll, kqueue uses the same function to register and wait for events, and multiple event sources may be registered and modified using a single call. Thechangelist array can be used to pass modifications (changing the type of events to wait for, register new event sources, etc.) to the event queue, which are applied before waiting for events begins.nevents is the size of the user suppliedeventlist array that is used to receive events from the event queue.

EV_SET(kev,ident,filter,flags,fflags,data,udata);

A macro that is used for convenient initialization of astruct kevent object.

See also

[edit]

OS-independent libraries with support for kqueue:

Kqueue equivalent for other platforms:

  • on Solaris, Windows and AIX:I/O completion ports. Note that completion ports notify when a requested operation has completed, whereaskqueue can also notify when a file descriptor is ready to perform an I/O operation.
  • on Linux:
    • epoll system call has similar but not identical semantics.
    • inotify is a Linux kernel subsystem that notices changes to the filesystem and reports those to applications.

References

[edit]
  1. ^abcJonathan Lemon (2000)."kqueue, kevent — kernel event notification mechanism".BSD Cross Reference.FreeBSD,OpenBSD,NetBSD,DragonFly BSD.
  2. ^abcJonathan Lemon (2001-05-01).Kqueue: A generic and scalable event notification facility(PDF).Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference.USENIX (published June 25–30, 2001).
  3. ^"Connection processing methods".nginx.org.
  4. ^Andrew Alexeev (2012)."§14. nginx". In Amy Brown; Greg Wilson (eds.).The Architecture of Open Source Applications, Volume II: Structure, Scale and a Few More Fearless Hacks.Lulu.com.ISBN 9781105571817.
  5. ^libkqueue onGitHub
  6. ^kqueue(2) – FreeBSD System CallsManual

External links

[edit]
TheFreeBSD Project
FreeBSD
Subsystems
Scheduling
Virtualisation
Storage
Networking
Other
People
Derivatives
open-source
proprietary
TheOpenBSD Project
Operating system
Related projects
People
Organizations
Publications
TheNetBSD Project
Operating system
Related projects
Notable subsystems
File systems andstorage
Firewalls andnetworking
Operating system
OS-level virtualisation
File systems,storage
Firewalls,networking
Subsystems
People
Versions
Mac OS X
OS X
macOS
Predecessors
Applications
Core
applications
Developer
Tools
Xcode
Former
Utilities
Former
Technologies,
user interface
Deprecated
Discontinued
Retrieved from "https://en.wikipedia.org/w/index.php?title=Kqueue&oldid=1317212447"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp