Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   CPU usage program (http://www.velocityreviews.com/forums/t542801-cpu-usage-program.html)

Sethu 10-08-2007 03:16 PM

CPU usage program
 
Hi everybody,

Can anyone give me a simple program which would consumes more CPU
usage (more than 50%) in windows?

Thanks,
Sethu


=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= 10-08-2007 03:40 PM

Re: CPU usage program
 
On 2007-10-08 17:16, Sethu wrote:
> Hi everybody,
>
> Can anyone give me a simple program which would consumes more CPU
> usage (more than 50%) in windows?


int main()
{
while (true) {}
}

I welcome anyone to write a smaller one.

Of course, this will never consume more than 50% CPU on a multi-core
system, but you can always run more instances of it.

--
Erik Wikström

Zeppe 10-08-2007 03:58 PM

Re: CPU usage program
 
Erik Wikström wrote:
> On 2007-10-08 17:16, Sethu wrote:
>> Hi everybody,
>>
>> Can anyone give me a simple program which would consumes more CPU
>> usage (more than 50%) in windows?

>
> int main()
> {
> while (true) {}
> }
>
> I welcome anyone to write a smaller one.


int main(){for(;;);}

Regards,

Zeppe

Victor Bazarov 10-08-2007 04:35 PM

Re: CPU usage program
 
Erik Wikstrm wrote:
> On 2007-10-08 17:16, Sethu wrote:
>> Hi everybody,
>>
>> Can anyone give me a simple program which would consumes more CPU
>> usage (more than 50%) in windows?

>
> int main()
> {
> while (true) {}
> }
>
> I welcome anyone to write a smaller one.


Yours:
int main(){while(true){}}

Mine:
int main(){while(1);}

Zeppe's:
int main(){for(;;);}

At least 4 and 5 symbols smaller (respectively). :-)

> [..]


V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



Shadowman 10-08-2007 05:18 PM

Re: CPU usage program
 
Erik Wikström wrote:
> On 2007-10-08 17:16, Sethu wrote:
>> Hi everybody,
>>
>> Can anyone give me a simple program which would consumes more CPU
>> usage (more than 50%) in windows?

>
> int main()
> {
> while (true) {}
> }
>
> I welcome anyone to write a smaller one.
>

int main() {main();}

> Of course, this will never consume more than 50% CPU on a multi-core
> system, but you can always run more instances of it.
>



--
SM
rot13 for email

Rolf Magnus 10-08-2007 05:33 PM

Re: CPU usage program
 
Shadowman wrote:

> Erik Wikström wrote:
>> On 2007-10-08 17:16, Sethu wrote:
>>> Hi everybody,
>>>
>>> Can anyone give me a simple program which would consumes more CPU
>>> usage (more than 50%) in windows?

>>
>> int main()
>> {
>> while (true) {}
>> }
>>
>> I welcome anyone to write a smaller one.
>>

> int main() {main();}


This should produce a compile error. Calling main within your program is
forbidden.


Justin Spahr-Summers 10-08-2007 09:00 PM

Re: CPU usage program
 
On Oct 8, 12:33 pm, Rolf Magnus <ramag...@t-online.de> wrote:
> Shadowman wrote:
> > Erik Wikstrm wrote:
> >> On 2007-10-08 17:16, Sethu wrote:
> >>> Hi everybody,

>
> >>> Can anyone give me a simple program which would consumes more CPU
> >>> usage (more than 50%) in windows?

>
> >> int main()
> >> {
> >> while (true) {}
> >> }

>
> >> I welcome anyone to write a smaller one.

>
> > int main() {main();}

>
> This should produce a compile error. Calling main within your program is
> forbidden.


Can you cite chapter and verse? I'm not criticizing what you're
saying... I'd just like official verification of it.


Victor Bazarov 10-08-2007 09:39 PM

Re: CPU usage program
 
Justin Spahr-Summers wrote:
> On Oct 8, 12:33 pm, Rolf Magnus <ramag...@t-online.de> wrote:
>> Shadowman wrote:
>>> Erik Wikstrm wrote:
>>>> On 2007-10-08 17:16, Sethu wrote:
>>>>> Hi everybody,

>>
>>>>> Can anyone give me a simple program which would consumes more CPU
>>>>> usage (more than 50%) in windows?

>>
>>>> int main()
>>>> {
>>>> while (true) {}
>>>> }

>>
>>>> I welcome anyone to write a smaller one.

>>
>>> int main() {main();}

>>
>> This should produce a compile error. Calling main within your
>> program is forbidden.

>
> Can you cite chapter and verse? I'm not criticizing what you're
> saying... I'd just like official verification of it.


[basic.start.main]/3 begins with words "The function main shall
not be used (3.2) within a program."

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask



=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= 10-08-2007 09:47 PM

Re: CPU usage program
 
On 2007-10-08 23:00, Justin Spahr-Summers wrote:
> On Oct 8, 12:33 pm, Rolf Magnus <ramag...@t-online.de> wrote:
>> Shadowman wrote:
>> > Erik Wikström wrote:
>> >> On 2007-10-08 17:16, Sethu wrote:
>> >>> Hi everybody,

>>
>> >>> Can anyone give me a simple program which would consumes more CPU
>> >>> usage (more than 50%) in windows?

>>
>> >> int main()
>> >> {
>> >> while (true) {}
>> >> }

>>
>> >> I welcome anyone to write a smaller one.

>>
>> > int main() {main();}

>>
>> This should produce a compile error. Calling main within your program is
>> forbidden.

>
> Can you cite chapter and verse? I'm not criticizing what you're
> saying... I'd just like official verification of it.


[basic.start.main]/3 "The function main shall not be used within a program."

--
Erik Wikström

=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?= 10-08-2007 09:48 PM

Re: CPU usage program
 
On 2007-10-08 18:35, Victor Bazarov wrote:
> Erik Wikstr�m wrote:
>> On 2007-10-08 17:16, Sethu wrote:
>>> Hi everybody,
>>>
>>> Can anyone give me a simple program which would consumes more CPU
>>> usage (more than 50%) in windows?

>>
>> int main()
>> {
>> while (true) {}
>> }
>>
>> I welcome anyone to write a smaller one.

>
> Yours:
> int main(){while(true){}}
>
> Mine:
> int main(){while(1);}
>
> Zeppe's:
> int main(){for(;;);}
>
> At least 4 and 5 symbols smaller (respectively). :-)


Yes, I asked for that. Though I was thinking more in terms of the size
of the executable.

--
Erik Wikström


All times are GMT. The time now is 09:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.