wait (or sleep) for current thread 
Author Message
 wait (or sleep) for current thread

Is there a simple call that will pause (or sleep in Unix terminology)
the current thread for several milli-seconds? It could be something
like setting a timer, but I'm not trying to get an interrupt to call
another function for a fixed interval, I just want the calling thread
to wait for a short period, as in 5 or 10 milli-seconds. And I'd like
it to be a one shot sort of thing when its called, not something that's
periodic.

Thanks in advance.

B^2



Fri, 15 Nov 2002 03:00:00 GMT  
 wait (or sleep) for current thread
In Win32 there is a Sleep!

(Note that Sleep is not very precise, if you want precision you have to
look at multimedia timers or other stuff)

Bye,
Rui Lopes



Quote:
> Is there a simple call that will pause (or sleep in Unix terminology)
> the current thread for several milli-seconds? It could be something
> like setting a timer, but I'm not trying to get an interrupt to call
> another function for a fixed interval, I just want the calling thread
> to wait for a short period, as in 5 or 10 milli-seconds. And I'd like
> it to be a one shot sort of thing when its called, not something
that's
> periodic.

> Thanks in advance.

> B^2


Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 16 Nov 2002 03:00:00 GMT  
 wait (or sleep) for current thread
Sleep(ms);

Someday I've got to write an essay about timing. There is no way you
will reliably get intervals in the 5-10ms range on NT, and it is next
to impossible on Win9x.  Even with multimedia timers, you are still at
the mercy of the scheduler, which means you can be preempted by
interrupts, system threads, higher-priority application threads, etc.

If you do Sleep(5) in Win9x, you'll get scheduled on the average
27.5ms later, which is a probability based on a uniform distribution
of the 55ms quantum time, which represents the nominal worst case if
everything is in your favor. It usually isn't.

The best I ever got out of Unix was 10ms resolution, subject to the
same problems (the X server usually did us in), and that was the
special Real-Time Mach kernel. This is about a factor of 20 too coarse
for real-time computer music, for example.

Repeat this mantra: "NT is not a real-time system..."

For serious realtime, see www.vci.com, a realtime kernel which runs
under NT.
                        joe



Quote:
>Is there a simple call that will pause (or sleep in Unix terminology)
>the current thread for several milli-seconds? It could be something
>like setting a timer, but I'm not trying to get an interrupt to call
>another function for a fixed interval, I just want the calling thread
>to wait for a short period, as in 5 or 10 milli-seconds. And I'd like
>it to be a one shot sort of thing when its called, not something that's
>periodic.

>Thanks in advance.

>B^2


Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Sat, 16 Nov 2002 03:00:00 GMT  
 wait (or sleep) for current thread
On Tue, 30 May 2000 04:19:53 -0400, Joseph M. Newcomer

Quote:

>Repeat this mantra: "NT is not a real-time system..."

What's your opinion about using REALTIME_PRIORITY_CLASS for the
periods when accurate timing is required.

SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);

Steve
--

Steve Wolstenholme
Neural Network Applications for Windows
http://www.tropheus.demon.co.uk



Sat, 16 Nov 2002 03:00:00 GMT  
 wait (or sleep) for current thread
Sleep(n) where n is the number of milliseconds to sleep.  Remember that this
time is simply an estimated sleep time since other, higher priority threads
may be executing when the Sleep ends.  Also, the resolution of n is limited
to the system clock resolution.

Mike Ober.


Quote:
> Is there a simple call that will pause (or sleep in Unix terminology)
> the current thread for several milli-seconds? It could be something
> like setting a timer, but I'm not trying to get an interrupt to call
> another function for a fixed interval, I just want the calling thread
> to wait for a short period, as in 5 or 10 milli-seconds. And I'd like
> it to be a one shot sort of thing when its called, not something that's
> periodic.

> Thanks in advance.

> B^2




Sat, 16 Nov 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Linux-GCC-Wait/Sleep/Delay??

2. Waiting uninterruptible in Win95 (sleep() don't work)

3. Threads, Memory Leak, how to wait for thread to close

4. thread auto delete and waiting for thread handle to terminate

5. determining if current thread is main thread

6. Determine if current thread is a worker thread

7. Wake Sleeping Thread?

8. Restarting a sleeping thread

9. Thread.Sleep

10. Thread.Sleep

11. Sleep a Thread for only 1 msec

12. Can we wakeup other threads which are sleeping?

 

 
Powered by phpBB® Forum Software