[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: select() n poll()



On Fri, 28 Jul 2000, Sunil Soman wrote:

+ Im trying to write a lil chat client/server. Im using select in the client 
+ for polling stdin and a socket. I tried using poll too:
+ with select - %CPU=0.01 with poll:%CPU=12
+ Isnt poll supposed to work the same as select() ??

Read <http://www.ddj.com/articles/1998/9809/9809e/9809e.htm> to note the
difference.

To quote from the same page:

<QUOTE>
Poll versus Select

                The poll() system call is a similar routine that
originated in System V Release 3.2 UNIX and has recently been added to
FreeBSD. The main difference is that poll() takes an array of structures,
instead of three bitmasks, to describe which file descriptors and events
should be examined.

                Each function has some advantages and disadvantages:
select() allows time-outs to be measured in microseconds, while poll only
allows tenths of a second. select() can only monitor for "input ready,"
"output ready," and "something else," while poll() supports many kinds of
file-type-specific events.

                Within the kernel, the main difference is that poll() can
check for more events, and the file-specific routine specifies which
events occurred. Since the functions called by selscan check a single
event, and return nonzero if that event happened, the same file-specific
function can serve both purposes.
</QUOTE>

HTH,
Sharad.