delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/02/26/12:37:42

X-Spam-Check-By: sourceware.org
Date: Mon, 26 Feb 2007 09:37:14 -0800
From: Christopher Layne <clayne AT anodized DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: does usleep() sleep more than it's supposed to?
Message-ID: <20070226173714.GB22638@ns1.anodized.com>
References: <45E292D6 DOT 30906 AT gmail DOT com>
Mime-Version: 1.0
In-Reply-To: <45E292D6.30906@gmail.com>
User-Agent: Mutt/1.5.11
X-Assp-Spam-Prob: 0.00000
X-Assp-Whitelisted: Yes
X-Assp-Envelope-From: clayne AT ns1 DOT anodized DOT com
X-Assp-Intended-For: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Mon, Feb 26, 2007 at 03:57:10PM +0800, Carlo Florendo wrote:
> Good Day,
> 
> I'm writing an application that requires time precisions up to the
> microsecond level.  However, I put a hard-coded adjustment of
> 9000 microseconds since usleep() seems to sleep on the average of
> 9000 microseconds more than it's supposed to, at least on my
> system.  I could work with up to 2000 microseconds for
> function overhead but 9000 microseconds seems to be too long.

Without using POSIX Realtime extensions, you will *never* attain
consistent granularity at the microsecond level with any sleep()
function.

Think about it - on a preemptive multiprocess OS - the minimum
intervals the OS uses for handing out timeslices to all processes
contained within the current environment (and also the associated
forced sleeping of processes who have used too many of their
timeslices within a given interval) will always limit your
granularity.

-cl

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019