public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: "Bill Rugolsky Jr." <brugolsky@telemetry-investments.com>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][4/4] poll()/select() timeout behavior
Date: Fri, 20 Feb 2004 20:13:28 -0800	[thread overview]
Message-ID: <20040220201328.609fe4e2.akpm@osdl.org> (raw)
In-Reply-To: <20040220210452.GE1912@ti19.telemetry-investments.com>

"Bill Rugolsky Jr." <brugolsky@telemetry-investments.com> wrote:
>
> This patch forces select() to wait *at least* the specified timeout if
> no events have occurred, same as poll(). The SUSv3 man page for select(2)
> says:
> 
>    "If the timeout parameter is not a null pointer, it specifies a maximum
>    interval to wait for the selection to complete. If the specified
>    time interval expires without any requested operation becoming ready,
>    the function shall return."
> 
> Additionally:
> 
>    "If the requested timeout interval requires a finer granularity than
>    the implementation supports, the actual timeout interval shall be
>    rounded up to the next supported value."
> 
> Unfortunately, fixing the fencepost error places a hard lower limit of
> 1/HZ on the time slept, and increases the average minimum sleep time
> threefold, from 1/(2*HZ) jiffy to 3/(2*HZ).

I'm inclined to live with the current behaviour rather than
risk breaking existing apps.

> 
> --- linux/fs/select.c	2004-02-20 14:29:11.000000000 -0500
> +++ linux/fs/select.c	2004-02-20 14:30:18.326814232 -0500
> @@ -313,8 +313,8 @@
>  		if (sec < 0 || usec < 0 || usec >= 1000000)
>  			goto out_nofds;
>  
> -		if ((unsigned long) sec < (MAX_SCHEDULE_TIMEOUT-1) / HZ - 1) {
> -			timeout = ROUND_UP(usec, 1000000/HZ);
> +		if ((unsigned long) sec < (MAX_SCHEDULE_TIMEOUT-2) / HZ - 1) {
> +			timeout = ROUND_UP(usec, 1000000/HZ) + 1;
>  			timeout += sec * (unsigned long) HZ;
>  		} else {
>  			timeout = MAX_SCHEDULE_TIMEOUT-1;

  reply	other threads:[~2004-02-21  4:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-20 21:04 [PATCH][4/4] poll()/select() timeout behavior Bill Rugolsky Jr.
2004-02-21  4:13 ` Andrew Morton [this message]
2004-02-21 16:18   ` Jamie Lokier
2004-02-21 19:27     ` Bill Rugolsky Jr.

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=20040220201328.609fe4e2.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=brugolsky@telemetry-investments.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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