mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamie Lokier <lk@tantalophile.demon.co.uk>
To: lost@l-w.net
Cc: Andries.Brouwer@cwi.nl, dean-list-linux-kernel@arctic.org,
	jcwren@jcwren.com, linux-kernel@vger.kernel.org
Subject: Re: select() - Linux vs. BSD
Date: Sat, 2 Jun 2001 23:46:40 +0200	[thread overview]
Message-ID: <20010602234640.A1290@pcep-jamie.cern.ch> (raw)
In-Reply-To: <UTC200106010816.KAA162273.aeb@vlet.cwi.nl> <Pine.LNX.4.21.0106011030330.10964-100000@skaro.l-w.net>
In-Reply-To: <Pine.LNX.4.21.0106011030330.10964-100000@skaro.l-w.net>; from lost@l-w.net on Fri, Jun 01, 2001 at 10:38:15AM -0600

lost@l-w.net wrote:
> Of course, not looking at the sets upon a zero return is a fairly obvious
> optimization as there is little point in doing so.

No; a fairly obvious optimisation is to avoid calling FD_ZERO if you
can clear the bits individually when you test them.

When you examine the sets, you can clear each bit that you examine and
then you know you have a zero set.  Then you can set only the relevant
bits for the next call to select().

If you can't rely on the sets being cleared on a timeout, then you
will have to call FD_ZERO in that case, or you will have to go through
the list of descriptors and clear them individually.  (This can be
avoided but it means keeping track of state between successive calls
to select()).  This is contrary to the non-timeout case, where you
stop checking bits when you have counted N of them set.

So you see, there is a handy optimisation if you can assume the sets
are zeroed on timeout.

-- Jamie

  reply	other threads:[~2001-06-02 21:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01  8:16 Andries.Brouwer
2001-06-01 16:38 ` lost
2001-06-02 21:46   ` Jamie Lokier [this message]
2001-06-03  2:13     ` lost
  -- strict thread matches above, loose matches on Subject: below --
2001-06-03  2:47 John Chris Wren
2001-06-03  3:31 ` Mike Castle
2001-06-03  7:52 ` David Schwartz
2001-06-01 17:33 Andries.Brouwer
2001-05-29 15:55 John Chris Wren
2001-05-29 17:34 ` Mike Castle
2001-05-29 19:51 ` Alan Cox
2001-05-29 20:50   ` lost
2001-05-29 21:06 ` dean gaudet
2001-05-31  1:40 ` Dr. Kelsey Hudson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010602234640.A1290@pcep-jamie.cern.ch \
    --to=lk@tantalophile.demon.co.uk \
    --cc=Andries.Brouwer@cwi.nl \
    --cc=dean-list-linux-kernel@arctic.org \
    --cc=jcwren@jcwren.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lost@l-w.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®