In-kernel device drivers support select by implementing a callback called poll. This driver's callback is supposed to do two things. First, it should return the current state of a file descriptor--a combination of being readable, writable, or having exceptions. Second, it should provide a pointer to one of the driver's internal wait queues that will be awakened whenever the state changes. The poll call itself should never block--it should just instantaneously report what the current state is.
FUSD's implementation of selectable devices is different, but attempts to maintain three properties that we thought to be most important from the point of view of a client using select. Specifically:
The FUSD kernel module keeps a cache of the driver's most recent answer for each file descriptor, initially assumed to be 0. When the kernel module's internal poll callback is activated, it:
In addition, the cached value's readable bit is cleared on every read; the writable bit is cleared on every write. This is necessary to prevent old poll state--which says ``device is readable''--from being returned out of the cache when it might be invalid. FUSD assumes that any read to a device can make it potentially unreadable. This mechanism is what causes an updated poll diff to be sent to a client before the previous one has been returned.
(this section isn't finished yet; fancy time diagrams coming someday)