From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 1 22:42:31 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 636E316A421 for ; Tue, 1 Nov 2005 22:42:31 +0000 (GMT) (envelope-from viktor.vasilev@stud.tu-darmstadt.de) Received: from lnx117.hrz.tu-darmstadt.de (lnx117.hrz.tu-darmstadt.de [130.83.174.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8BA4B43D45 for ; Tue, 1 Nov 2005 22:42:29 +0000 (GMT) (envelope-from viktor.vasilev@stud.tu-darmstadt.de) Received: from ilium.0xdeadc0de.net (ABC216.ram1st.wh.tu-darmstadt.de [130.83.20.203]) (authenticated bits=0) by lnx117.hrz.tu-darmstadt.de (8.12.10/8.12.10) with ESMTP id jA1MgINb011294 for ; Tue, 1 Nov 2005 23:42:19 +0100 Received: by ilium.0xdeadc0de.net (nbSMTP-1.00) for uid 1001 viktor.vasilev@stud.tu-darmstadt.de; Tue, 1 Nov 2005 23:42:24 +0100 (CET) Date: Tue, 1 Nov 2005 23:42:23 +0100 From: Viktor Vasilev To: freebsd-hackers@freebsd.org Message-ID: <20051101224223.GA737@ilium.0xdeadc0de.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 5.4-RELEASE i386 User-Agent: mutt-ng devel (FreeBSD) X-TUD-HRZ-MailScanner: Found to be clean X-TUD-HRZ-MailScanner-SpamCheck: X-MailScanner-From: viktor.vasilev@stud.tu-darmstadt.de Subject: select(2) timeout precision X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2005 22:42:31 -0000 Hello fellow hackers, I'm writing a piece of code, that basically does the following in a thread: tick.tv_sec = 0; tick.tv_usec = 10000; gettimeofday(&t1, NULL); select(0, NULL, NULL, NULL, &tick); gettimeofday(&t2, NULL); With FreeBSD 5.4-RELEASE I almost constantly get ~20000 microseconds delta. That is with 100HZ kernel on PIII 500MHz or Sempron 64 2800+ running in i386 mode. It also doesn't matter if I use usleep or select. I've tested the code on linux with 2.6.11 kernel and there I not only get the 10000 us sleep, but I can also set it to 5000 us and it still runs very accurately. So my question is, is this a FreeBSD limitation of some kind, and is there a way to circumvent it? Best regard, Viktor -- I think and think for months and years. Ninety nine times, the conclusion is false. The hundredth time I am right. -- Albert Einstein