#### Archived

This topic is now archived and is closed to further replies.

This topic is 5668 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone! I have a question about something I''m doing. I recently came across a neat little program called CPUKiller. Some of you might have come across it too. Basically it slows down your CPU so that you can run older programs that run too fast on newer faster computers. Anyhow I was thinking about how I would go about doing this. I created a little program that simply detects user input via the arrow keys and creates a certain number of threads that count to 100 or so. This serves to slow down the CPU, the only thing is it is not as stable as the program CPUKiller. I get little spats in time where my game speeds up then slows down, creating a jerky like motion sometimes. Is this the right approach? the only other alternative that I can think of would be to reduce the amount of memory available to windows by having another little program allocate alot of memory for "bogus" things like objects, etc.. would this work and be a little more stable than the thread approach? Any input would be very much appreciated as I''m trying to figue this thing out... Thanks!! ~Bolt

##### Share on other sites
If you''re trying to slow down your own program, forget about it and implement framerate-independent motion.

##### Share on other sites
No, I''m not trying to slow down my program. I''m trying to slow down my machine (CPU) so that other programs will INTENTIONALLY run slow. (hehe) kinda funny trying to make the computer run slow, but that''s what I want it to do.,.

##### Share on other sites
quote:
Original post by Boltimus
the only other alternative that I can think of would be to reduce the amount of memory available to windows by having another little program allocate alot of memory for "bogus" things like objects, etc.. would this work and be a little more stable than the thread approach?

No. That would just increase the amount of paging, and would not provide a ''stable'' slowdown.

##### Share on other sites
Change the settings in BIOS, the multiplier and FSB speeds. That is of course if you''re bios lets ya do that and yer cpu isn''t locked as some are so u could only change the FSB if that was the case. I guess u want to do it with software not hardware, but it would work just fine.

##### Share on other sites
Another program that does that is moslow. If you are intent on making your own I would suggest this as a much more stable way of sucking cycles. Have one thread that is set to the highest priorities. Check out SetThreadPriority and SetPriorityClass api''s. Then burn time in a loop and check a high res timer often. Every so often you should Sleep(). By timing how long you run vs. how much time has elapsed you should be able with a little tweaking to tell it what percentage of processor time to take.

Jack

##### Share on other sites
just create a SINGLE realtime thread which MUST call sleep at regular intervals (ie give up some timeslice). realtime priority is VERY dangerous so use caution when testing.

##### Share on other sites
This is just a thought I had while reading your post. I think it would be pretty difficult to get this to work right, but you could write your program to use the debugging facilities of the cpu (and the OS). For example, set the CPU to break after each instruction and then you could implement a short delay or something. I think this would give you the most exact control over how fast the other program is running. This will of course not slow down everything on your computer, only the program that your ''speedkiller'' is attached to.

As I said, just a thought, I don''t know much about writing debuggers for windows.

##### Share on other sites
quote:
Original post by Boltimus
Hey everyone! I have a question about something I''m doing. I recently came across a neat little program called CPUKiller. Some of you might have come across it too. Basically it slows down your CPU so that you can run older programs that run too fast on newer faster computers. Anyhow I was thinking about how I would go about doing this. I created a little program that simply detects user input via the arrow keys and creates a certain number of threads that count to 100 or so. This serves to slow down the CPU, the only thing is it is not as stable as the program CPUKiller. I get little spats in time where my game speeds up then slows down, creating a jerky like motion sometimes. Is this the right approach? the only other alternative that I can think of would be to reduce the amount of memory available to windows by having another little program allocate alot of memory for "bogus" things like objects, etc.. would this work and be a little more stable than the thread approach? Any input would be very much appreciated as I''m trying to figue this thing out...

Thanks!!

~Bolt

I am not entirely sure how these programs work, but I would guess they either make some modification to system setting or they just tie up CPU time. Of course you wouldn''t have to worry about it the original program had based the speed of his game on something like the system timer instead of how fast the CPU can a loop.

##### Share on other sites
Thanks for all those ideas! I never thought about the sleep idea let alone setting one thread that has a high priority! Every so often I would keep getting a seg fault.. hehe Also even when one thread was made it would really slow down my CPU too much..I like the idea of timing the thread then giving control back to windows. I''ll try a combination of all the recomendations and see what works! thx!!

##### Share on other sites
keep in mind that
while(1)
{
for (int a = 0; a < 99999999; a++);
sleep(1);
}
still isn''t 100% stable. you''d still have bursts of cpu usage for 1 ms at a time. depending what you are doing, 1ms might be alot of time. multiple threads at high priority will help in this case.

##### Share on other sites
You know that Sleep is not accurate to the millisecond, right ? Depending on the O.S., i''ve seen the minimum time vary from 8 ms to 40 ms.

Y.

##### Share on other sites
Well, I tried the one string approach. I set it''s class to the highest I could, and controlled a global variable via WM_KEYDOWN which in turn controlled the sleepiness of the thread and for some reason it still doesn''t work. Now here''s the wierd thing. If I place a Sleep() command in my main program, I actually get better control over the CPU usage then if I had placed it in the thread!?? If I don''t place it in the main program, and I just have the program create a simple thread (what I mean by simple is that it only looks for a global variable to change from a 0 to 1 so that it can terminate) then my CPU usage goes right away to 100%! ack!! I used sysmon to monitor the number of threads created by CPUKILLER and it seems to only create 2 threadds, however, I''m having little success slowing down the CPU with sleep, etc.... Is there another way..perhaps memory resources? Every where I read, it says that the most limiting factor in the early days of multitasking (and for the most part multi-threading) was memory and the ability of the OS to move it around. If I hog the memory resources from windows (via a HUGE NEW command, or whatever) do you think that might be the ticket?

Thanks!!

~Bolt

##### Share on other sites
Since its open source, you could modify bochs (a multiplatform x86 emulator) to do a wait between instructions. This would likely give you near 100% control of the cpu speed (though you would be limited in what maximum speed you could set)

##### Share on other sites
Boltimus, sleep doesn''t slow the CPU down. It speeds it up. The Sleep call really tells the OS to run some other thread for the amount of time that you''re sleeping.

If you have something like

while(1) {     for(int i=0; i < 90000; i++)           sleep(n);}

The ''CPU speed'' of your other processess will get slower as n goes down.

Is that what you were doing? Your posting seemed to indicate that you thought sleep would slow the CPU by itself.

##### Share on other sites
as i said before a single realtime thread should be good enough. though the debugger idea is spiffy as well.

btw, you cant just create a worker thread which you set to realtime and expect it to work properly. you must have your main process thread as a realtime thread. worker threads are subjected to the priority of the process thread, and a such dont get a "true" priority as you set it. it has to do with how windows handles time slices.

though in any case, a process at time critical (realtime) will actually supercede the OS. i fail to see how it gives less control.

you may consider using a multimedia timer with a callback that excutes every x milliseconds (your callback better only take x milliseconds to execute). then do some busy work (ie all the sqrt() function or something, DONT call sleep() it only affects the giving up of your timeslice).

unfortunatly unless you know how to write asm code to time a pc, you wont be able to come up wont be able to come up with a decent busy loop thats accurate enough for what you want.

##### Share on other sites
quote:
Original post by Anonymous Poster

while(1) {     for(int i=0; i < 90000; i++)           sleep(n);}

Looks like you forgot the ; at the end of the for-loop.

• ### Forum Statistics

• Total Topics
628641
• Total Posts
2983981

• 10
• 18
• 20
• 13
• 9