AuroraRuntime/Include/Aurora/Threading/README SleepNote.txt

10 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-06-12 17:28:51 +00:00
A common misconception states that you can't and shouldn't yield with above MS precision bc "tehe kernels and timers are slow."
Such propagators believe that because the "kernel tick" or "timer tick" is slow, the res must therefore be bad.
In reality, kernel sleep requests are fed into the kernels respective scheduling or similar io subsystem to yield given the target unit of time.
The frequency of a Linux kernel, for instance, only determines the software timer interrupt driving preemption. In the most basic of implementation,
such is generally true across all kernels. The problem is, timed sleeps aren't in anyway dependent on thread context preemption, and are instead mostly
dependent on a reschedule of the context itself, leading to the infamous inconsistencies in yield times. So far as PC timer resolution and thread
switching through <current year - 15> to <current year> are concerned, we are countless orders of magnitude ahead of 1000 units per second, or 1000MS.
We therefore implement SleepNs as the much required higher resolution alternative to MS, regardless of if you can actually reach your target sleep
period accurately.