Getting the CPU to run at full load is actually quite simple – just write an infinite loop and the OS will allocate more and more time slices to it. However, modern processors are multi-core. For example, my computer has 4 cores, so you’ll find the CPU stays around 25-27% and never reaches 100%.
To reach 100%, you just need to use multithreading.
The most provocative statement I saw today was:
“I dare you to make the CPU draw a circle.” I was completely stunned at that moment…
Now let’s look at the 50% case. The book “Beauty of Programming” says that alternating between “sleep for one time slice, work for one time slice” should achieve 50%. But I found the results were not great. Even using GetTickCount, the effect was poor because the computer has other programs running as well.
| |