Hi,
I tried
stdlib.h

sleep(10);

to no avail.
I need a resolution of millisec range
Thx
Jack

Re: How to suspend operation/threads in VC by adebaene

adebaene
Wed Jun 07 02:06:08 CDT 2006


Jack a =E9crit :

> Hi,
> I tried
> stdlib.h
>
> sleep(10);
>
> to no avail.
> I need a resolution of millisec range

Under NT/2000/XP, the scheduler quantum is of 10 or 15 ms (depending on
the version), so you won't get below this.

What do you think you need to sleep wih a ms resolution? Please explain
what's your purpose, and we may come up with a better solution.

Arnaud
MVP - VC


Re: How to suspend operation/threads in VC by Ulrich

Ulrich
Wed Jun 07 02:08:41 CDT 2006

Jack wrote:
> stdlib.h
>
> sleep(10);
>
> to no avail.

What was the problem? What happened, what did you expect to happen?

Other than that, the win32 API has Sleep().

> I need a resolution of millisec range

Your OS can't guarantee such a resolution due to preemption, what are you
trying to do?

Uli


Re: How to suspend operation/threads in VC by Jack

Jack
Wed Jun 07 02:18:05 CDT 2006

Hi guys,
I'm emulating a sensor processor device,
a SBC is sending info to this device thru USB (telling it to get somethin'
off the sensors) ,
I want to suspend the thread for a while to get synchronous results. like
getting a bunch of data each 50ms.... Thanks
Jack

"Ulrich Eckhardt" <eckhardt@satorlaser.com>
???????:pkail3-aqv.ln1@satorlaser.homedns.org...
> Jack wrote:
>> stdlib.h
>>
>> sleep(10);
>>
>> to no avail.
>
> What was the problem? What happened, what did you expect to happen?
>
> Other than that, the win32 API has Sleep().
>
>> I need a resolution of millisec range
>
> Your OS can't guarantee such a resolution due to preemption, what are you
> trying to do?
>
> Uli
>



Re: How to suspend operation/threads in VC by William

William
Wed Jun 07 11:22:50 CDT 2006

<adebaene@club-internet.fr> wrote in message
news:1149663968.181403.189980@c74g2000cwc.googlegroups.com...
>> sleep(10);
>>
>> to no avail.
>> I need a resolution of millisec range
>
> Under NT/2000/XP, the scheduler quantum is of 10
> or 15 ms (depending on the version), so you won't
> get below this.

Well, Windows makes no guarantess as to latency, but if the OP recasts his
snippet as

timeBeginPeriod(1);

// ...

Sleep(1);

// ...

timeEndPeriod(1);

in a high priority thread or on a lightly-loaded system, the chances are
good that he will get much better results.

Regards,
Will



Re: How to suspend operation/threads in VC by Andre

Andre
Wed Jun 07 11:30:48 CDT 2006

Jack wrote:
> Hi,
> I tried
> stdlib.h
>
> sleep(10);
>
> to no avail.
> I need a resolution of millisec range
> Thx
> Jack


Hi,

you could try the function "timeBeginPeriod", which increases the timer
irq rate and therefore increases also the timer resolution.

e.g.:

#include <Mmsystem.h>
#pragma comment(lib, "Winmm.lib")
...
timeBeginPeriod(1);



Should set the resolution to 1 millisecond. On some systems the system
clock may be drifting due to this call.



//
// If you don't need the high resolution you should call
timeEndPeriod(1);


Hope this helps.
Andre