Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: David Wilkinson <no-reply@xxxxxxxxxxxx>
- Date: Fri, 16 Nov 2007 05:34:47 -0500
Joseph M. Newcomer wrote:
Perhaps because you asked it to? If you write a computation that consumes all the CPU, it
is going to, guess what, consume all the CPU! And that's what you've written! So
presumably you WANT to consume 100% of the available CPU time.
I have no idea what while(1) means anyway. while(TRUE) makes sense; while(true) makes
sense. What's an integer got to do with it?
Joe:
Well, while(1) and while(TRUE) are in fact the same thing. while(1) is often used in C where there is no bool type.
I agree that while(true) is preferred, but all these constructs produce warnings in recent VC versions at level 4 (at least in C++ mode), and the preferred usage is for(;;). I find this ugly, but have started using it since I started compiling at level 4.
--
David Wilkinson
Visual C++ MVP
.
- Follow-Ups:
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Joseph M . Newcomer
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Tom Serface
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- References:
- Why INFINITE loop in a thread occupy so much CPU time??
- From: lostlander
- Re: Why INFINITE loop in a thread occupy so much CPU time??
- From: Joseph M . Newcomer
- Why INFINITE loop in a thread occupy so much CPU time??
- Prev by Date: Re: Internationalization and Localization
- Next by Date: Re: MDI & SDI
- Previous by thread: Re: Why INFINITE loop in a thread occupy so much CPU time??
- Next by thread: Re: Why INFINITE loop in a thread occupy so much CPU time??
- Index(es):
Relevant Pages
|