[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sleep in microsecond or nanosecond

From: olafBuddenhagen
Subject: Re: sleep in microsecond or nanosecond
Date: Mon, 9 Aug 2010 23:22:56 +0200
User-agent: Mutt/1.5.20 (2009-06-14)


On Tue, Jul 06, 2010 at 08:44:30AM +0800, Da Zheng wrote:

> I need a program to sleep in several microseconds, but neither
> nanosleep() nor usleep() can work. They sleep at least 10ms. So it
> seems the only option is to use loop and Linux kernel does so as well
> for udelay() and ndelay(). Then I need high resolution timing. I think
> I can use TSC, but it's better to be system independent. There is
> clock_gettime() in POSIX, but surprisingly it's not implemented in
> glibc in Hurd. Any suggestions?

For the record: I still think that the best solution would be a special
kernel call that does precise delays; automatically using delay loops
for short sleeps, or the best available timer for longer ones. This
stuff is pretty machine-specific, and thus -- at least in the Mach world
-- it's a job for the kernel. (Though even L4 does timer handling in the
kernel AIUI -- after all, the kernel needs some timer support itself, to
implement process scheduling...)

Of course such a kernel call would still be a bit rough for really short
delays, because of the general kernel call overhead. I guess it would be
good enough for most applications though.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]