Re: [PATCH] /dev/epoll update ...

Dan Kegel (dank@kegel.com)
Tue, 25 Sep 2001 01:12:26 -0700


"Christopher K. St. John" wrote:
> Ok, just to confirm. Using the language of BSD's
> kqueue[1]. you've got:
>
> a) report the event only once when it occurs aka
> "edge triggered" (EV_CLEAR, not EV_ONESHOT)
>
> b) continuously report the event as long as the
> state is valid, aka "level triggered"

Right, and kqueue() can't even represent the 'level triggered' style --
or at least it isn't clear from the paper that it can! True "level triggered"
would require that the kernel track readiness of the affected file descriptors.

> The Banga99 paper certainly appears to describe an
> "edge triggered" interface:
>
> "Our new API follows the event-based approach. In
> this model the kernel simply reports a stream of
> events to the application. ... The kernel does
> not track the readiness of any descriptor ... "
>
> Libenzi-/dev/epoll, being a partical implementation
> of the Banga99 mechanism, is also edge-triggered.
>
> OTOH, the Provos/Lever Linux /dev/poll paper describes
> what appears to be a "level triggered" interface.

Agreed.

> Now for a question: My initial impression was that
> Solaris-/dev/poll, in contrast to Linux /dev/poll, was
> edge-triggered. That would explain why it might be
> more efficient that Linux-/dev/poll.
>
> But I don't have a copy of Solaris, handy, so I
> can't confirm. Do you know for sure? (Or is part of
> my analysis wrong?)

Solaris /dev/poll is definitely level-triggered; see Poller_test.cc in
http://www.kegel.com/dkftpbench/dkftpbench-0.33.tar.gz, which verifies this.
Poller_devpoll.cc is a thin wrapper around /dev/poll, and it definitely exhibits
level-triggered behavior with both Solaris and Linux /dev/poll.

(I later extended Poller to support edge-triggered notifications from the OS,
and translate them to level-triggered notification for the user app.
Poller_sigio.cc and Poller_sigfd.cc are somewhat fatter wrappers around O_ASYNC,
and achieve level-triggered behavior only with cooperation from the application,
which has to call clearReadiness(fd) when the OS returns EWOULDBLOCK!
Surely the OS could do that internally, eh?)

Java's Selector in JDK 1.4 will have level-triggered behavior, not
edge-triggered behavior, btw.
- Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/