🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9602

Re: Sleep() funtion in XP

#9602
From: Oliver Rutsch
Date: Tue, 22 Jun 2004 11:01
37 lines
2078 bytes
Hi Francisco,

> Oooops . I forget to tell that i tried it too with this version of Sleep.
> 
> void SleepB (DWORD t)
> {
> 
>   DWORD StartTime =GetTickCount();
>   n=0;
>   while (GetTickCount()- StartTime < t)
>        {
>         n++;
>        }
> }
> 
> But It  DELAYS 15 ms or 16 ms too!?!?
> 
> I undersatand that the thread suspend execution but there is much diference.
> 
> However this method consumes too much CPU %.

1. The resolution of GetTickCount is not enough for measuring 
milliseconds. Use QueryPerformanceCounter and QueryPerformanceFrequency 
to get exact results.

2. Use timeBeginPeriod() and timeEndPeriod() to get more precise Sleeps. 
When your work load is low this will work quite accurate.

3. Increase the priority of your thread (if you have one). But remember 
that you don't have to use busy loops with high priority.

4. If that's not enough use a multimedia timer (as said here before)

5. If all of that doesn't help then write your own driver or use a 
special kind of hardware for that purpose.

Bye, Oliver.
Technical Details
Message-ID: <40d81191@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40d7dda3@newsgroups.borland.com> <40d7ecf1$1@newsgroups.borland.com> <40d7f263@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,78dca2a71f1a0ab4
X-Google-Attributes: gid10cc67,public
Date: Tue, 22 Jun 2004 13:01:49 +0200
From: Oliver Rutsch <orutsch@sympatec.com>
User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Sleep() funtion in XP
References: <40d7dda3@newsgroups.borland.com> <40d7ecf1$1@newsgroups.borland.com> <40d7f263@newsgroups.borland.com>
In-Reply-To: <40d7f263@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 217.6.163.139
Message-ID: <40d81191@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1087902097 217.6.163.139 (22 Jun 2004 04:01:37 -0700)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail