The Sleep(ms) command in windows is causing threads to release their timeslices. Is there an equivalent Sleep(ms) command that halts the thread but does not release the timesli开发者_JAVA百科ce?
You don't want your thread to sleep (aka suspend), you want to stall it. Do that with a simple loop:
#include <time.h>
void stall(unsigned ms){
clock_t goal = clock()+ms;
while(goal>clock());
}
// or maybe higher resolution with some performance profiling functions...
Strange.
A way to do that is to make your thread execute a loop till the end of the periode needed.
A better solution may be to give the thread handling the device a high priority. But anyway, Windows is not very suitable for real-time systems...
精彩评论