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!
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!
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 04:39 AM. Reason: grammer
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.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
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).
I agree, but never cease to be amazed at how many people think of that as a good thing.
Make everythign a thread, that way your game is scalable (omfg I just advocated scalability in games).
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"
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 05:26 PM.
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"
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.
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"
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.
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.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.