Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Control CPU usage of a program? (http://www.velocityreviews.com/forums/t447884-control-cpu-usage-of-a-program.html)

Robert 08-21-2005 03:31 PM

Control CPU usage of a program?
 
Hi all,

I am writing programs of algorithms using C++ and C. When I run the
programs,
I found the programs take 100 percent of the CPU usage and I cannot run
any other program.
How to control the CPU usage percentage?
For example, let the program take 30 percent of the CPU usage? Thanks!

BTW, the circumstance is Windows 2k and XP.

Best regards,
Robert


Victor Bazarov 08-21-2005 06:52 PM

Re: Control CPU usage of a program?
 
Robert wrote:
> I am writing programs of algorithms using C++ and C. When I run the
> programs,
> I found the programs take 100 percent of the CPU usage and I cannot
> run any other program.
> How to control the CPU usage percentage?
> For example, let the program take 30 percent of the CPU usage? Thanks!


There is no way in C++ to do that. The C++ language is specified
without considering any other programs. All that is given to the
host operating system to control.

> BTW, the circumstance is Windows 2k and XP.


Then go to 'comp.os.ms-windows.programmer.win32' or any relevant
newsgroup from the 'microsoft.public.*' hierarchy.

V



Sumit Rajan 08-21-2005 06:57 PM

Re: Control CPU usage of a program?
 

"Robert" <zhushenli@gmail.com> wrote in message
news:1124638273.563224.237320@g49g2000cwa.googlegr oups.com...
> Hi all,
>
> I am writing programs of algorithms using C++ and C. When I run the
> programs,
> I found the programs take 100 percent of the CPU usage and I cannot run
> any other program.
> How to control the CPU usage percentage?



Off-topic. Please see:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
--
Sumit Rajan <sumit.rajan@gmail.com>



Chris Hills 08-21-2005 07:15 PM

Re: Control CPU usage of a program?
 
In article <DYSdnTHJKNLtUJXeRVn-qA@comcast.com>, Victor Bazarov
<v.Abazarov@comAcast.net> writes
>Robert wrote:
>> I am writing programs of algorithms using C++ and C. When I run the
>> programs,
>> I found the programs take 100 percent of the CPU usage and I cannot
>> run any other program.
>> How to control the CPU usage percentage?
>> For example, let the program take 30 percent of the CPU usage? Thanks!

>
>There is no way in C++ to do that.


Yes there is! You can do most things with C++ but how it is done it is
Off topic for this NG.

>The C++ language is specified
>without considering any other programs.


Not really. AFAIK the standard just specifies the language it does not
specify other programs or OS

> All that is given to the
>host operating system to control.


What if there is no host operating system? What if this "program" is
the OS? IF the program is the OS then it can clearly control the CPU
loading.

>> BTW, the circumstance is Windows 2k and XP.

>
>Then go to 'comp.os.ms-windows.programmer.win32' or any relevant
>newsgroup from the 'microsoft.public.*' hierarchy.


We agree here. This is a Windows programing problem. I am sure that he
will be able to implement something in C++ to solve the problem he is
just asking in the wrong place.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ chris@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/





All times are GMT. The time now is 08:00 PM.

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57