Control CPU usage of a program?

R

Robert

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
 
V

Victor Bazarov

Robert said:
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
 
C

Chris Hills

Victor Bazarov said:
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.
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top