void Sleep(DWORD dwMilliseconds);
- Calling Sleep alows the thread to volunatarily give up the remainder of its time slice.
- The System makes the thread not schedulable for approxmitely the number of milliseconds specified. That's right-if you tell the system you want to sleep for 100 miliseconds, you will sleep approximitely that long, but possivly several seconds or minutes more. Remember that Windows is not a real-time operating system. Your thread will probably wake up at theright time, but whether it does depends on what else is going on in the system.
- You can call Sleep and pass INFINITE for the dwMilliseconds parameter. This tells the system to never schedule the thread. This is not a useful thing to do. It is much better to havethe thread exit and to recover its stack and kernel object.
- You can pass 0 to Sleep. This tells the system that the calling thread relinquishes the remainder if its time slice, and it forces the system to schedule another thread. However, the system can reschedule the thread that just called Sleep. This will happen if there are no more schedulable threads at the same priority or higher.
On Windows Via C/C++ page 177.
No comments:
Post a Comment