1 Comment

I recently encountered this issue and the workaround that I have used is to sleep for a tiny amount of time (minimal duration allowed by the clock, which if you use the right clock is much shorter than the time it actually takes for a kernel to put a task to sleep and wake it up).

This is more expensive than a true scheduler yield would be, since the kernel has to read the TSC to query the sleep deadline. But it does fulfill the intended purpose : since the kernel cannot keep executing a sleeping task, it will switches to other tasks while waiting for the sleep duration to be elapsed.

Expand full comment