From owner-freebsd-bugs Mon Dec 27 17:40: 6 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 6720514D1F for ; Mon, 27 Dec 1999 17:40:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id RAA72190; Mon, 27 Dec 1999 17:40:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Date: Mon, 27 Dec 1999 17:40:02 -0800 (PST) Message-Id: <199912280140.RAA72190@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Mikhail Teterin Subject: Re: kern/13644 Reply-To: Mikhail Teterin Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR kern/13644; it has been noted by GNATS. From: Mikhail Teterin To: jasone@FreeBSD.org Cc: freebsd-bugs@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org, lawlopez@cisco.com, jseger@FreeBSD.org Subject: Re: kern/13644 Date: Mon, 27 Dec 1999 20:38:58 -0500 (EST) jasone@FreeBSD.ORG once stated: =Synopsis: select(2) timer inaccurate, especially with -pthread = =State-Changed-From-To: open->closed =State-Changed-By: jasone =State-Changed-When: Mon Dec 27 12:39:03 PST 1999 =State-Changed-Why: =The kernel implementation of sleep() uses tvtohz() to calculate the =number of ticks that tsleep() should sleep. tvtohz() adds one tick to =allow for the possibility that the current tick is almost expired. =select() guarantees that it will sleep at least as long as the timeout =before returning an empty result (0). This is NOT what the man page states: If timeout is a non-nil pointer, it specifies a maximum interval to wait for the selection to complete. =If the number of ticks passed to tsleep() were reduced by one, this =guarantee would no longer be possible. = =This is not a bug; it is an artifact of correct implementation. If you =need higher resolution, use nanosleep(). In particular, TCL's after(n) implementation relies on this fact... People responsible for the TCL port may need to take a note... Because in TCL 8.x's unix/tclUnixEvent.c there is a function Tcl_Sleep(ms) and the comments in it say: /* * The only trick here is that select appears to return early * under some conditions, so we have to check to make sure that * the right amount of time really has elapsed. If it's too * early, go back to sleep again. */ Please, consider reviewing this again without the implementation details obstructing the view. :-) -mi To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message