Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

CPU usage program

 
 
UINDEX
Guest
Posts: n/a
 
      10-09-2007
On Oct 8, 11:16 pm, Sethu <(E-Mail Removed)> wrote:
> Hi everybody,
>
> Can anyone give me a simple program which would consumes more CPU
> usage (more than 50%) in windows?
>
> Thanks,
> Sethu


this is a sample program which can consume one core.
call OnTest N(CPU number) times to consumes more CPU usage (more than
50%).

DWORD WINAPI UseOneCore(void * p)
{
while(true);
return 0;
}


void CMy00Dlg::OnTest()
{
::CreateThread(NULL,0,UseOneCore,NULL,0,NULL);
}

 
Reply With Quote
 
 
 
 
Zeppe
Guest
Posts: n/a
 
      10-09-2007
Erik Wikström wrote:
> 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."
>

Restated also in [expr.call]/9: Recursive calls are permitted, except to
the function named main (3.6.1).

Regards,

Zeppe
 
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