Control CPU usage of a program?

D

Davy

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,
Davy
 
C

Castreuil Anthony

Davy schreef:
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,
Davy

You can't really tell "Take 30 percent", but you can fiddle with thread
priority.
 
R

Robert Gamble

Davy said:
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!

There is no way to control this in Standard C, it is off-topic here.
BTW, the circumstance is Windows 2k and XP.

Good, ask in a group that focuses on those systems.

Robert Gamble
 
G

Gordon Burditt

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.

A reasonable OS will not let one looping program lock out others
unless the priorities have been set in a non-default manner to give
your program absolute priority over everything else (sometimes
called a "real time priority").

Since Windows 2000 is often used as a server, I find it difficult
to believe it's got a problem like this without some amount of
tweaking settings inappropriately (by either the admin or the
viruses). After all, it manages to cope with a busy webserver with
neither handling web pages nor running viruses locking each other
out.
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.

I recommend reading the documentation that came with your OS.
Incidentally, I see no reason to limit your program from taking
100% of the CPU *IF THERE'S NOTHING ELSE TO RUN*. Otherwise, it
just wastes that CPU time.

Gordon L. Burditt
 
R

Randy Howard

Davy wrote
(in article
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?

You've asked this same question in multiple newsgroups now
(starting new individual threads in each by the way). You have
been given answers, please don't keep asking.
 
Joined
Nov 4, 2012
Messages
2
Reaction score
0
Paid writers!

I see there are paid writers in here...

Davy asks a legit question, and bs-answers like read the manual for your OS is one of the worse I've ever seen! Who are you working for? Microsoft?
 
Last edited:
Joined
Nov 4, 2012
Messages
2
Reaction score
0
PS! I found a program that might help both Davy and me: donationcoder dot com/Software/Mouser/proctamer/
 

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,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top