usleep

Andrew Pogrebennyk marduk at portaone.com
Fri Feb 22 15:28:43 UTC 2008


Sharad,
Additionally, this C routine is considered obsolete (unlike shell
command by the same name). The interaction of this function with SIGALRM
and other timer functions such as sleep(), alarm(), setitimer(), and
nanosleep() is unspecified. Additionally, its use in multi-threaded
programs can lead to somewhat surprising results. Use nanosleep(2) or
setitimer(2) instead.

Sharad Chandra wrote:
> Hi Guys,
> 
> 	Does usleep work for you? i just saw it is implemented over nanosleep which 
> passes a struct timeval to "select".
> 
> on my system, one of instance for usleep and select sleep value.
> 
> provided
> (sec).(microsec) => select (sleep) usleep (sleep)
> 0.000000 => select: 0.000004 usleep: 0.000008
> 0.000001 => select: 0.002199 usleep: 0.001758
> 0.000002 => select: 0.004125 usleep: 0.001688
> 0.000003 => select: 0.005546 usleep: 0.001999
> 0.000004 => select: 0.006645 usleep: 0.002045
> 0.000005 => select: 0.001374 usleep: 0.002034
> 0.000006 => select: 0.002480 usleep: 0.001996
> 0.000007 => select: 0.006715 usleep: 0.001998
> 0.000008 => select: 0.002297 usleep: 0.001662
> 0.000009 => select: 0.002635 usleep: 0.001999
> 0.000010 => select: 0.003717 usleep: 0.001988
> 
> --
> 
> Thanks
> Sharad Chandra

-- 
Sincerely,
Andrew Pogrebennyk




More information about the freebsd-hackers mailing list