What is the most time-consuming operation on the CPU?

You need to simulate some blocking operation. I think some calculation in the loop is a good option. Question. It is better to assume that the CPU worked longer?
June 14th 19 at 18:54
6 answers
June 14th 19 at 18:56
Sleep will not work, its runtime can pokypat. - paula.Ste commented on June 14th 19 at 18:59
what it means to pokypali? Execution will switch to another task and come back to your after the specified time. Exactly the same thing will happen if you are blocking operations

And when using the cycle it will happen, the system and other programs also need a processor - turner.Beahan commented on June 14th 19 at 19:02
June 14th 19 at 18:58
It is better to assume that the CPU worked longer?

rep nop
June 14th 19 at 19:00
Yes, anything, even an empty cycle - main iterations for more. And disable the optimization options, and the compiler may remove the loop from the executable file.
June 14th 19 at 19:02
a|1=a^a=a*a*a*a*a...=a+a+a+a+a...=a++;a + a;++a;a++;...
And then try to calculate 123546789/1
June 14th 19 at 19:04
Time to interrupt the idle loop.
June 14th 19 at 19:06
all these mathematical operations in loops are very well optimized by the hardware, even if you disable optimization in the compiler.
therefore, the most expensive operation - is not predictable, the conditional transition from random data fits perfectly under it, the processor will not be able to accurately predict this conditional branch.
well, blocking operations are emulated just slips.

Find more questions by tags Programming