For some reason (no precise one, just got the idea in mind to try and slow down a system), I decided to try to make a program that would try to take up CPU cycles.
I figured out that I should change the process priority and thread priority so it would run in real time. Great there, I lock up the system with my loop logic.
Now, I figured out, too, that I can insert a small sleep delay in the thread every so often and can give back the CPU to other parts of the system. I can tweak this by changing when I use the sleep delay, and how long the sleep delay will take.
Now we come to the question. I'm trying to think through a way to reasonably configure how much CPU this program uses by putting a control on this form. I'm thinking I can run the CPU loop with full CPU for a second and count how many times it runs. Hopefully, this will present a reasonable standard to relate time, which is what sleep uses, to how long I'm in this loop.
If I set my delay to 10ms, then I should reasonably be able to see a 90% CPU utilization if I set the delay to go every 90ms according to my loop? I guess, if anything, I'm trying to see a mathematical relationship that would help...
----------
Measurement is not management.
I figured out that I should change the process priority and thread priority so it would run in real time. Great there, I lock up the system with my loop logic.
Now, I figured out, too, that I can insert a small sleep delay in the thread every so often and can give back the CPU to other parts of the system. I can tweak this by changing when I use the sleep delay, and how long the sleep delay will take.
Now we come to the question. I'm trying to think through a way to reasonably configure how much CPU this program uses by putting a control on this form. I'm thinking I can run the CPU loop with full CPU for a second and count how many times it runs. Hopefully, this will present a reasonable standard to relate time, which is what sleep uses, to how long I'm in this loop.
If I set my delay to 10ms, then I should reasonably be able to see a 90% CPU utilization if I set the delay to go every 90ms according to my loop? I guess, if anything, I'm trying to see a mathematical relationship that would help...
----------
Measurement is not management.