Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Bart van Ingen Schenau <bart@xxxxxxxxxxxxxxx>
- Date: Mon, 10 Sep 2007 22:34:13 +0200
Miguel Guedes wrote:
<snip>
{
target = clock() + (clock_t)(timer*(float)CLOCKS_PER_SEC);
while(clock() < target);
Although this is a standard conforming way to wait for a certain time
period, it is actually not a very friendly way on a multi-user system.
This loop probably consumes 100% CPU time while it is doing nothing.
For this kind of task, it is advisable to look for a implementation
specific method. Functions like Sleep (Windows) and sleep/usleep (unix)
come to mind.
Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
.
- References:
- Another Tricky Problem I am Messing With (Not Homework)
- From: joebenjamin
- Re: Another Tricky Problem I am Messing With (Not Homework)
- From: Miguel Guedes
- Another Tricky Problem I am Messing With (Not Homework)
- Prev by Date: Re: Anyone have any ideas on this one.....
- Next by Date: Re: What is this noalias thing Dennis Ritchie is railing about ?
- Previous by thread: Re: Another Tricky Problem I am Messing With (Not Homework)
- Next by thread: Re: Another Tricky Problem I am Messing With (Not Homework)
- Index(es):
Relevant Pages
|