Subject: Re: Importing kqueue's from FreeBSD...
To: Charles M. Hannum <email@example.com>
From: Luke Mewburn <firstname.lastname@example.org>
Date: 03/20/2001 08:58:02
On Mon, Mar 19, 2001 at 01:40:10PM -0800, Charles M. Hannum wrote:
> On Mon, Mar 19, 2001 at 04:21:45PM -0000, email@example.com wrote:
> > I would prefer something that uses strings to identify events
> > to userland so new event types could be created without
> > much fear that they would conflict. By qualifying the
> > event by a subsystem type, the probablility of conflict
> > between two different events would be minimal.
> As I've already pointed out elsewhere, copying strings in and out of
> the kernel for poll(2)/select(2)-like functionality would be a
> significant CPU hit, which partly defeats the point of doing this in
> the first place.
In order to solve eeh's preferences, there was an alternative
solution; support a string->kqueuefilter lookup:
struct kevent event;
int fd, type;
kq = kqueue();
if (kq < 0)
/* the following is new */
type = kqueue_filtertype("read");
event.ident = fd;
event.filter = type; /* instead of EVFILT_READ */
event.flags = EV_ADD | EV_ENABLE;
if (kevent(kq, event, 1, NULL, 0, NULL) < 0)
In this case, int kqueue_filtertype(const char *) checks the kernel
for a list of already registered filters and returns an int to be used
as the filter type. When support is added for the functionality to
allow extra filters to be registered, that registration function could
also take the string as the identifier.
It shouldn't matter if the string->id conversion returns different
numbers for the same string across reboots; it only has to be
consistent per reboot.
I think this solve's eeh's (and thorpej's) concerns about allowing
arbitrary filters to be defined, without requiring strings to be used
at all times. There's still a potential for namespace clash (if two
third party lkm vendors choose the same string), but it's far less
likely than two vendors choosing the same int.
PS: excuse me if this isn't coherent; I'm feeling unwell.