Subject: Implementing poll(2)
To: None <tech-kern@NetBSD.ORG>
From: Charles M. Hannum <mycroft@MIT.EDU>
List: tech-kern
Date: 07/17/1996 00:26:34
I've written an implementation of the SVR4 system call poll(2), which
I'll be committing `soon'. For the uneducated, poll(2) is similar to
select(2), except that it uses an array of {fd,event mask} pairs
rather than 3 bitmasks. The advantages of poll(2) over select(2) are:
1) The input/output array is reusable, so you don't have to copy or
rebuild it on every invocation.
2) Any application can implement a variable-sized poll(2) array, and
even keep it compacted, trivially. In contract, the size of a fd_set
is fixed at compile time, and must be due to interface deficiencies.
3) The poll(2) interface allows new types of events to be added.
To implement the interface efficiently, I have mutated the old
internal fo_select, vop_select, and d_select interfaces to take an
event bitmask as an argument, and return a bitmask of the events
found. (Also, I've renamed them to fo_poll, vop_poll, and d_poll,
respectively).
Since this affects all tty drivers, port maintainers will need to
update their drivers. For AFS and most other file systems, all you
need to do is rename `*fs_select' to `*fs_poll', and change
`vop_select_desc' to `vop_poll_desc' in the vnops table. (I've
updated all of the ISA and generic drivers and file systems, so there
are numerous examples.)
Applications, and especially libraries, in our source tree should be
converted to use poll(2), although for most this is not critical.