Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 API  





2 See also  





3 References  





4 External links  














kqueue






فارسی

 

Edit links
 









Article
Talk
 

















Read
Edit
View history
 








Tools
   


Actions  



Read
Edit
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Cite this page
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 






From Wikipedia, the free encyclopedia
 


Kqueue is a scalable event notification interface introduced in FreeBSD 4.1 in July 2000,[1][2] also supported in NetBSD, OpenBSD, DragonFly BSD, and macOS. Kqueue was originally authored in 2000 by Jonathan Lemon,[1][2] then involved with the FreeBSD Core Team. Kqueue makes it possible for software like nginx to solve the c10k 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 the kernel and userland. Thus, it is possible to modify event filters as well as receive pending events while using only a single system calltokevent(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 numerous 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, furthermore kqueue provides a way to use user-defined events in addition to the ones provided by the kernel.

Some other operating systems which traditionally only supported select(2) and poll(2) also currently provide more efficient polling alternatives, such as epollonLinux and I/O completion portsonWindows and Solaris.

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

API[edit]

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

int kqueue(void);

Creates a new kernel event queue and returns a descriptor.

int kevent(int kq, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout);

Used to register events with the queue, then wait for and return any pending events to the user. In contrast to epoll, kqueue uses the same function to register and wait for events, and multiple event sources may be registered and modified using a single call. The changelist 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 supplied eventlist 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 a struct kevent object.

See also[edit]

OS-independent libraries with support for kqueue:

Kqueue equivalent for other platforms:

References[edit]

  1. ^ a b c Jonathan Lemon (2000). "kqueue, kevent — kernel event notification mechanism". BSD Cross Reference. FreeBSD, OpenBSD, NetBSD, DragonFly BSD.
  • "kqueue, kevent, EV_SET — kernel event notification mechanism". OpenBSD manual page server.
  • "kqueue, kevent -- kernel event notification mechanism". DragonFly On-Line Manual Pages.
  • ^ a b c Jonathan 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).
  • ^ "Connection processing methods". nginx.org.
  • ^ 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.
  • ^ libkqueueonGitHub
  • ^ kqueue(2) – FreeBSD System Calls Manual
  • External links[edit]


    Retrieved from "https://en.wikipedia.org/w/index.php?title=Kqueue&oldid=1219442308"

    Categories: 
    Events (computing)
    BSD software
    FreeBSD
    OpenBSD
    NetBSD
    DragonFly BSD
    MacOS
    Operating system APIs
    Operating system technology
    System calls
    Hidden categories: 
    Articles with short description
    Short description is different from Wikidata
    Articles needing additional references from April 2024
    All articles needing additional references
     



    This page was last edited on 17 April 2024, at 19:48 (UTC).

    Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



    Privacy policy

    About Wikipedia

    Disclaimers

    Contact Wikipedia

    Code of Conduct

    Developers

    Statistics

    Cookie statement

    Mobile view



    Wikimedia Foundation
    Powered by MediaWiki