Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Jun 2001 13:29:31 -0700
From:      "Jonathan Graehl" <jonathan@graehl.org>
To:        "'Dag-Erling Smorgrav'" <des@ofug.org>
Cc:        <arch@freebsd.org>, <jlemon@freebsd.org>
Subject:   RE: New kqueue filter
Message-ID:  <000301c101a3$62b04220$6dfeac40@straylight.com>
In-Reply-To: <xzp66deux0a.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Jonathan Lemon can speak to this better than I, but I believe this is
because kevents are supposed to be level and not edge-sensitive (that
is, "there is data waiting", not "data became available").  The filter
would run the first time to place the event in the kqueue tentatively,
and then (some time later, when some other process could have removed
the event) when the user retrieves events with kevent, the filters run
again to verify that the condition still exists.  Perhaps it is possible
to specify for the kqueue framework code whether an event should be
retested (is edge or level sensitive).  

Admittedly, you still have to check for failure when acting on the
verified events, because there would be a brief period of time between
kevent and your action where a process could remove the condition (e.g.
read all the data from the socket buffer) before you can.

Perhaps in the future, kqueue will be streamlined and special-cased for
optimum efficiency.  For now, it is so far ahead of select/poll (and
async I/O with queued posix real-time signals) that nobody has bothered
- and perhaps kqueue is simply not used by that many of the mainstream
programs, which, with their focus on portability, neglect kqueue because
no equivalent facility is available on Linux/Solaris/whatever.

I haven't actually examined much kernel code at all, but I did read a
paper on the kqueue design and debugged a connect()
kqueue/socket-error-notification bug.  Feel free to correct me ;)

http://www.google.com/search?q=cache:Mh5ixqePXvM:people.freebsd.org/~jle
mon/kqueue.pdf+jlemon+kqueue+paper&hl=en
(text version of http://people.freebsd.org/~jlemon/kqueue.pdf)
(there may be a more recent paper, that was just my best guess through
google.com)

--
Jonathan Graehl 
  http://jonathan.graehl.org/

> The only problem I've experienced with this patch is that it 
> seems the filter always runs twice (even when it succeeds the 
> first time, though it only returns to userland the second 
> time).  This is possibly a bug in the kqueue framework code.
> 
> DES
> -- 
> Dag-Erling Smorgrav - des@ofug.org
> 
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000301c101a3$62b04220$6dfeac40>