Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > CPU usage program

Reply
Thread Tools

CPU usage program

 
 
Sethu
Guest
Posts: n/a
 
      10-08-2007
Hi everybody,

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

Thanks,
Sethu

 
Reply With Quote
 
 
 
 
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
Posts: n/a
 
      10-08-2007
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
 
Reply With Quote
 
 
 
 
Zeppe
Guest
Posts: n/a
 
      10-08-2007
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
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      10-08-2007
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


 
Reply With Quote
 
Shadowman
Guest
Posts: n/a
 
      10-08-2007
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
 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      10-08-2007
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.

 
Reply With Quote
 
Justin Spahr-Summers
Guest
Posts: n/a
 
      10-08-2007
On Oct 8, 12:33 pm, Rolf Magnus <(E-Mail Removed)> 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.

 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      10-08-2007
Justin Spahr-Summers wrote:
> On Oct 8, 12:33 pm, Rolf Magnus <(E-Mail Removed)> 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


 
Reply With Quote
 
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
Posts: n/a
 
      10-08-2007
On 2007-10-08 23:00, Justin Spahr-Summers wrote:
> On Oct 8, 12:33 pm, Rolf Magnus <(E-Mail Removed)> 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
 
Reply With Quote
 
=?UTF-8?B?RXJpayBXaWtzdHLDtm0=?=
Guest
Posts: n/a
 
      10-08-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Control CPU usage of a program? Davy C Programming 6 11-04-2012 02:46 AM
CPU usage program sethukr@gmail.com C Programming 14 10-14-2007 11:26 PM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:09 PM
retrieving CPU Usage and Memory Usage information in JAVA hvt Java 0 03-13-2007 01:07 PM
Control CPU usage of a program? Robert C++ 3 08-21-2005 07:15 PM



Advertisments