Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2008 14:37:48 +0100
From:      "Heiko Wundram (Beenic)" <wundram@beenic.net>
To:        freebsd-hackers@freebsd.org
Subject:   Re: usleep
Message-ID:  <200802221437.48293.wundram@beenic.net>
In-Reply-To: <200802221558.42443.sharadc@in.niksun.com>
References:  <200802221558.42443.sharadc@in.niksun.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Am Freitag, 22. Februar 2008 11:28:42 schrieb Sharad Chandra:
> 	Does usleep work for you? i just saw it is implemented over nanosleep
> which passes a struct timeval to "select".

Quoting from POSIX:

"""
The usleep() function will cause the calling thread to be suspended from 
execution until either the number of real-time microseconds specified by the 
argument useconds has elapsed or a signal is delivered to the calling thread 
and its action is to invoke a signal-catching function or to terminate the 
process. The suspension time may be longer than requested due to the 
scheduling of other activity by the system.
"""

See the last sentence, specifically.

So, yes, the behaviour you're seeing is pretty much expected, simply because 
_user_ processes are scheduled in timeslices, which depend on the HZ setting 
of the kernel.

-- 
Heiko Wundram
Product & Application Development



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802221437.48293.wundram>