Control CPU usage of a program?

Discussion in 'C Programming' started by Davy, Aug 21, 2005.

  1. Davy

    Davy Guest

    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
    Davy, Aug 21, 2005
    #1
    1. Advertising

  2. 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.
    Castreuil Anthony, Aug 21, 2005
    #2
    1. Advertising

  3. Davy wrote:
    > 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
    Robert Gamble, Aug 21, 2005
    #3
  4. >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
    Gordon Burditt, Aug 21, 2005
    #4
  5. Davy

    Randy Howard Guest

    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.


    --
    Randy Howard (2reply remove FOOBAR)
    Randy Howard, Aug 21, 2005
    #5
  6. Davy

    HalleHamar

    Joined:
    Nov 4, 2012
    Messages:
    2
    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: Nov 4, 2012
    HalleHamar, Nov 4, 2012
    #6
  7. Davy

    HalleHamar

    Joined:
    Nov 4, 2012
    Messages:
    2
    PS! I found a program that might help both Davy and me: donationcoder dot com/Software/Mouser/proctamer/
    HalleHamar, Nov 4, 2012
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert
    Replies:
    3
    Views:
    403
    Chris Hills
    Aug 21, 2005
  2. hvt
    Replies:
    0
    Views:
    1,210
  3. hvt
    Replies:
    0
    Views:
    1,469
  4. Sethu

    CPU usage program

    Sethu, Oct 8, 2007, in forum: C++
    Replies:
    11
    Views:
    635
    Zeppe
    Oct 9, 2007
  5. CPU usage program

    , Oct 8, 2007, in forum: C Programming
    Replies:
    14
    Views:
    628
    Peter Pichler
    Oct 15, 2007
Loading...

Share This Page