Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 1996 16:42:34 EST
From:      "Kaleb S. KEITHLEY" <kaleb@x.org>
To:        Matt Thomas <matt@lkg.dec.com>
Cc:        hackers@freefall.freebsd.org
Subject:   Re: Forgiving select() call. 
Message-ID:  <199605282042.QAA19909@exalt.x.org>
In-Reply-To: Your message of Tue, 28 May 1996 14:31:52 EST. <199605281431.OAA18898@whydos.lkg.dec.com> 

next in thread | previous in thread | raw e-mail | index | archive | help

> 
> In  <199605281118.HAA17563@exalt.x.org> , you wrote:
> 
> Since Kaleb mentioned Digital UNIX as one O/S that implements poll,
> I though it might be useful to elaborate on that a bit.
> Digital UNIX has both the poll(2) and select(2) system calls.  Both
> are syscalls in fact.  


Are you making a distinction between a "system call" and a "syscall"?
I did make a specific point of saying that Digital UNIX, among others,
has both select and poll as system calls, i.e. direct entries to the 
kernel -- not library calls.


> However, since poll has more functionality 
> that select the kernel infrastructure is build around poll rather
> than select.  


When you talk about additional functionality are you refering to 
the additional bits in events/revents? For example the extra bits
in revents like POLLHUP, which when returned in revents, tells you 
that the socket has closed rather than having to infer that the socket 
has closed when you get a POLLRD and ioctl(fd, FIONREAD, &bytes_to_read) 
returns zero in bytes_to_read?

Or that POLLNORM tells you that (any) data can be read, whereas POLLIN 
tells you only when normal priority data can be read, POLLPRI tells 
you when high priority data can be read, and POLLRDBAND tells you when 
non-zero priority data can be read? (What is the difference between
high priority data and non-zero band data?)

Or that POLLOUT tells you when zero band data can be written and 
POLLWRBAND tells you when non-zero band data can be written?

Using send/recv you can specify the MSG_OOB flag to send/receive
non-zero band data. Using putmsg/getmsg (spec'ed in Spec1170 but 
not available in FreeBSD) you can specify RS_HIPRI to send/receive 
high priority messages. My ignorance of TCP/IP will show when I ask 
whether there's a difference between non-zero band data and high 
priority messages. On systems that have both is there a difference 
between send(..., MSG_OOB) and putmsg(..., RS_HIPRI)?

The select exception mask is poorly documented. Stevens' "UNIX Network
Programming" and examination of the Net/2 and later sources reveals
that the exception mask, when used on a socket, means that high priority
data may be read. (N.B. Stevens also says that it is used to indicate 
"The presence of control status information to be read from the master 
side of a pseudo-terminal that has been put into packet mode." However 
I was unable to find any other select handler in the 2.1R sources that 
used the exception mask.) Also, there is no way, using select, to 
discover that high priority data may be written to a socket. One must 
resort to other mechanisms. In fact, when I looked at the interface 
between select and the socket code, it appeared that the socket code 
was not capable of supporting the richer set of conditions that poll 
(as defined in Spec1170) supports. I concluded that the best I could 
hope to accomplish at this time would be to mimic the poll support 
that SunOS has, i.e. only support POLLIN, POLLOUT, and POLLPRI.


> The select kernel code actually calls poll code in
> side the kernel.  Internally, the kernel uses a timeval; poll's ms
> timeout gets converted to a timeval.


That's similar to what I have for polltv and poll. Polltv takes a
timeval while poll takes an int that's converted in the kernel to 
a timeval and then merely calls polltv. The int argument in poll
could just as easily be converted in the library and then call
polltv, but since there's an open spot in <sys/syscall.h> that
corresponds to the SYS_poll entry on SunOS, I presumed that it was
just waiting for an implementation in order to be filled in, and 
polltv gets tacked onto the end of syscall list.

--

Kaleb KEITHLEY



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605282042.QAA19909>