Ah, I see. Personally I wanted to go into the kqueue() direction as introduced and used by the BSD systems. This solution looks very easy to use and is extremly flexible and extensible. It's basically a filedescriptor and you add a list of events (determined by id and a filter) you want to wait for.
Requiring use of Fnctl() or any other system call to alter the set of
events imposes too much overhead. On servers where the set of
descriptors of interest changes frequently, this kind of approach is a
serious loser.
Another point where select (and poll) wins is that there is a fast mapping from the input set to the result set - i.e., if you want to know "did event #5 occur?" you can find out in constant time, because it's just a fixed bitfield lookup. For all the other mechanisms that either return events one at a time or in a flat list, you have to iterate thru the list to look for "event #5". They have thus taken the linear search that the kernel does for select and kicked it out into userland, thus perceiving a great savings in kernel CPU time but not really improving life for the application developer. There is an obvious way to solve both of these problems with no additional cost - do both.
This approach completely eliminates any copying of event
records/descriptor lists between user/kernel space, so constructing
event lists and modifying them is essentially zero-cost. Also, since the
array of events remains in place, the application can inspect higher
priority events of interest by direct reference.
> I further suggested that to implement this cleanly, the entire AES could > be represented as a wrapper library around GEMDOS calls that talk to the > device driver. For example, appl_init() might open the device and get > the file handle, appl_exit() would close it, evnt_multi() would set > parameters and read from the device file handle and write into the > supplied return values, etc. Yes, this can be done. But the questions is if it's necessary. For backward compatibility you have to provide the old API anyway and if you want to use the new features you need to define a new API.
I'm interested in what other ideas you have on solving the "unified event loop" situation. I've already pitched one idea, but not yet heard specifically where the problems are that need to be redesigned.