Subject: Re: CVS commit: src/sys/kern
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-net
Date: 07/03/2006 12:29:26
--qftxBdZWiueWNAVY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jul 02, 2006 at 09:37:26PM +0900, YAMAMOTO Takashi wrote:
> [ moved from source-changes@ ]
>=20
> > |    > Log Message:
> > |    > Revert previous change to bump the socket low watermark to sock_=
loan_thresh.
> > |    > With sock_loan_thresh=3D4096, sb_lowat=3D=3Dsb_hiwat, and sowrit=
able will never
> > |    > be true (even if only a single byte is pending). Some programs (=
like screen)
> > |    > expect select() to return that a socket is writable on a socket =
when there
> > |    > is space to write to it. XXX: What is the right thing to do here?
> > |   =20
> > |    i guess the right thing is fixing the configure script...
> > |=20
> > | why is it wrong?
> >=20
> > This is the script; it writes 4 bytes to the socket, and expects that
> > the second select will return 2, one for the socket being readable,
> > and one for being writable. The socket "sowritable" test will always
> > fail if sb_hiwat =3D=3D sb_lowat and there are bytes in the queue.

I'm sorry, but I'm confused.

My understanding of how high and low water marks work is:

A process can write until the number of bytes pending is above the high
water mark when we come in. Assuming blocking i/o, said process then
blocks until we get to less than (or equal?) bytes in queue. We keep the=20
process blocked so that we don't spend a lot of time scheduling it and=20
de-scheduling it; when we're below lowwat, the idea is that the writer can=
=20
run for a while filling the queue.

Extrapolating to non-blocking i/o, I think it depends on if we have a bit=
=20
sitting around indicating "I'm blocked." If so, once we see we're over=20
highwat, we set said bit, and select will indicate we aren't writable=20
until we have less than lowwat in the buffer, at which time we clear the=20
bit and indicate writability.

If we don't have such a bit, I don't see why we don't indicate writability=
=20
if we have less than highwat bytes in the buffer.

If we have less than highwat bytes in the socket buffer, why is select not=
=20
indicating writability?

Take care,

Bill

--qftxBdZWiueWNAVY
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFEqXAWWz+3JHUci9cRAtnbAJ4g8IsviwaoXcM0fm9hrejA+voLZACdE8o+
DkH+UiT9UEHYV2FIQq9EP5s=
=v2Dc
-----END PGP SIGNATURE-----

--qftxBdZWiueWNAVY--