🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Sleep time resolution

#11370
From: Detlef
Date: Mon, 16 Feb 2004 14:23
38 lines
2818 bytes
Hi Rob,
the problem with Sleep( 1) on Microsoft Windows systems is, that the minimum
sleep time is a time slice ( and that is 10/15 ms, depending on the
processor type). On my current tests ( which I think are different from my
test years before) I recognized that a sleep bet 1 and 15 causes in real
sleeptimes of 15 - 18 ms, sleeps between 16 and 20 causes in real times of
around 32 ms.
That is the reason for looking another type of a sleep function.
Detlef

"Rob" <nospam@nonexistant.com> schrieb im Newsbeitrag
news:402d421b@newsgroups.borland.com...
> "Malcolm Smith" <mjfreelancing@optusnet.com.au> wrote in message
> news:402b6ed2$1@newsgroups.borland.com...
> > I made an observation a long time ago that Sleep(0) causes real problems
> in
> > tight loops.  Change it to Sleep(1) - all problems go away.
> >
>
> The reason that Sleep(0) can cause problems in tight loops is
> that all it does is yield the processor to other threads in priority
> order.   Higher priority threads will often get CPU resources,
> with or without the Sleep(0) as your thread will be preempted.
> Threads at equal priority will get some access to CPU
> resources, but will often be starved of CPU resources
> (eg other user apps will be starved by one that hogs resources).
> Lower priority threads are very likely to be starved of
> CPU resources (although the scheduler sometimes does
> things to address that, it often elects not to).
>
> Changing to Sleep(1) simply means that you slow down
> your loops, so that other apps have a larger timeslice in
> which to run and in which your tight loop is guaranteed
> not to.  The flip side of that is that your "tight loop" will
> take longer to complete.
>
>
>
Technical Details
Message-ID: <4030d231$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <402b4f78$1@newsgroups.borland.com> <402b6ed2$1@newsgroups.borland.com> <402d421b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3e6954a6a5dc7821
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-16 06:40:19 PST
Reply-To: "Detlef" <detlef.stute@seatec-gmbh.com>
From: "Detlef" <detlef.stute@seatec-gmbh.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <402b4f78$1@newsgroups.borland.com> <402b6ed2$1@newsgroups.borland.com> <402d421b@newsgroups.borland.com>
Subject: Re: Sleep time resolution
Date: Mon, 16 Feb 2004 15:23:15 +0100
Lines: 40
Organization: SEATEC GmbH
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 80.134.67.108
Message-ID: <4030d231$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076941361 80.134.67.108 (16 Feb 2004 06:22:41 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail