CPU Question

This is a discussion on CPU Question within the C++ Programming forums, part of the General Programming Boards category; Hey guys, i'm wondering if anyone could tell me a way to make my PC use more CPU than it ...

  1. #1
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625

    CPU Question

    Hey guys, i'm wondering if anyone could tell me a way to make my PC use more CPU than it does now in my game, even if it doesn't need it.
    Thanks in advance!

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    37
    if there is nothing more to calculate or more code to process in your binary how should your cpu use more register to do this job?
    Last edited by punkywow; 10-04-2009 at 05:39 AM. Reason: grammer

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I think OP has multiple cores and sees 50% or 25% CPU usage with Task Manager (one core is 100% busy, others are unused by the program).

    I think you might make your game use multiple threads. (E.g launch a number of threads with an endless do nothing loop. )

    Of course, if your game doesn't need more computing power, it would be rather pointless to want it to drain the computer of its resources.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    6,528
    Quote Originally Posted by anon View Post
    I think you might make your game use multiple threads. (E.g launch a number of threads with an endless do nothing loop. )
    To actually use all the CPUs (or in modern CPUs, the cores) it is also a good idea to associate particular threads with a particular processor. Otherwise the allocation of threads to processors - or balancing of processing load - is a bit in the lap of the gods (or the operating system).
    Quote Originally Posted by anon View Post
    Of course, if your game doesn't need more computing power, it would be rather pointless to want it to drain the computer of its resources.
    I agree, but never cease to be amazed at how many people think of that as a good thing.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy in reply to you, it is likely you deserve it. Suck it up, sunshine, and read this, this, and this before posting again.

  5. #5
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Make everythign a thread, that way your game is scalable (omfg I just advocated scalability in games).
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,901
    Quote Originally Posted by grumpy View Post
    To actually use all the CPUs (or in modern CPUs, the cores) it is also a good idea to associate particular threads with a particular processor. Otherwise the allocation of threads to processors - or balancing of processing load - is a bit in the lap of the gods (or the operating system).
    No, that is bad. That would hinder the ability for the OS to properly schedule the threads. It might interfere with power efficiency and stuff like that too.
    The OS probably knows better than you do, so let it handle it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by Sipher View Post
    Hey guys, i'm wondering if anyone could tell me a way to make my PC use more CPU than it does now in my game, even if it doesn't need it.
    Thanks in advance!
    You haven't mentioned wanting it to run faster, you just want to burn more electricity. You evil polluter you! In that case I hope you're the one paying the power bill, and that your game never runs on any other PC.

    If that's not how it is, then tell us the real issue: Is it really actually just running too slowly?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    6,528
    Quote Originally Posted by Elysia View Post
    No, that is bad. That would hinder the ability for the OS to properly schedule the threads. It might interfere with power efficiency and stuff like that too.
    The OS probably knows better than you do, so let it handle it.
    A goal of maximising resource usage of a program isn't exactly up there among a list of good things either.

    However, where I was coming from is that most modern operating systems have a way to go with regard to how they do load balancing (eg moving threads between processors to optimise usage). While things will undoubtedly improve as the state of art with operating system design improves, I'm not yet convinced that program designers - if such things are important to their programs - can accept such things on faith just yet.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy in reply to you, it is likely you deserve it. Suck it up, sunshine, and read this, this, and this before posting again.

  9. #9
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by grumpy View Post
    A goal of maximising resource usage of a program isn't exactly up there among a list of good things either.

    However, where I was coming from is that most modern operating systems have a way to go with regard to how they do load balancing (eg moving threads between processors to optimise usage). While things will undoubtedly improve as the state of art with operating system design improves, I'm not yet convinced that program designers - if such things are important to their programs - can accept such things on faith just yet.
    Actually most modern OS's do a great job of scheduling threads. They naturally assume that you want a thread to run as often as possible, which is true for 99.99% of applications, and schedule them accordingly, if you need a thread to run more often then give it a higher priority, if you know for a fact that you can schedule the threads of your application better than that, then you have the power to force threads to run on a particular processor, and to actively suspend and wake those threads.

    Personally I can count the number of times I have had to do this on one finger.

    If you just want to maximize resource use then this will do it (assuming windows) -
    Code:
    #include <window.h>
    
    DWORD WINAPI ThreadProc(LPVOID){
       DWORD Temp = 0;
       while(1) Temp++;
       return 0;
       }
    
    DWORD WINAPI main(){
       DWORD ThreadId;
       
       while(1){
          HANDLE hThread = CreateThread(NULL , 0 ,  0 , ThreadProc , NULL , 0 , &ThreadId);
          }
    
       return 0;
       }
    Last edited by abachler; 10-04-2009 at 06:26 PM.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Hmm, that's the closest thing to a fork bomb I've seen in ages! Of course you clearly want to have the spawned threads also being put to good use trying to create more threads themselves. Incrementing a variable continuously is hardly a good use of those poor threads time.
    There's one small flaw in that program however. No extra threads will actually be created because there is no message loop. CreateThread waits until a message is processed, IIRC.
    You could always swich CreateThread for CreateProcess for a more authentic touch.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    Quote Originally Posted by iMalc View Post
    Hmm, that's the closest thing to a fork bomb I've seen in ages! Of course you clearly want to have the spawned threads also being put to good use trying to create more threads themselves. Incrementing a variable continuously is hardly a good use of those poor threads time.
    There's one small flaw in that program however. No extra threads will actually be created because there is no message loop. CreateThread waits until a message is processed, IIRC.
    You could always swich CreateThread for CreateProcess for a more authentic touch.
    CreateThread does not wait until a message is processed. In fact the thread does not even have a message queue to begin with unless you specifically create one. The thread begins execution immediately, well, it get scheduled immediately, it has to wait tis turn in the queue liek every other thread.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  12. #12
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Quote Originally Posted by abachler View Post
    CreateThread does not wait until a message is processed. In fact the thread does not even have a message queue to begin with unless you specifically create one. The thread begins execution immediately, well, it get scheduled immediately, it has to wait tis turn in the queue liek every other thread.
    You're right. I think I was confusing it with CreateProcess.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  13. #13
    Registered User
    Join Date
    Jun 2005
    Posts
    6,528
    Quote Originally Posted by iMalc View Post
    You're right. I think I was confusing it with CreateProcess.
    A process also does not necessarily run a message loop. Consider the console application ....
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy in reply to you, it is likely you deserve it. Suck it up, sunshine, and read this, this, and this before posting again.

  14. #14
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Just to clear things up, i want it to use more CPU to increase the frames Per Second! And that because if an object if going too fast, by using realtime movement of course, it might and it will miss another object on its way if at the moment of modelling it doesn't collide but it does during "realtime". That's why i'm asking how can i increase the CPU usage for the game! That is all.

  15. #15
    The larch
    Join Date
    May 2006
    Posts
    3,573
    If the guesses about multiple cores are correct, then you could try multithreading.

    However, this doesn't really solve the problem for people who have a slower computer. I think the real solution is to change the way you detect collisions, so your game objects won't simply go through others. Game programming specialists probably know better answers, but one way might be to check for collisions for the intermediate positions of fast-moving objects.

    In my own very unpretentious game I have also capped the maximum delta time allowed (there cannot be more that 50 ms between logical updates) at which speed no game object can pass another undetected (of course this is not fool-proof, if faster objects were to be added).
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 01:14 PM
  2. CPU Usage so high
    By X PaYnE X in forum Windows Programming
    Replies: 9
    Last Post: 12-21-2003, 03:07 AM
  3. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  4. cpu temp
    By dP munky in forum Tech Board
    Replies: 36
    Last Post: 02-07-2003, 06:01 PM
  5. Replies: 72
    Last Post: 11-25-2002, 05:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21