3 ms·
From the article: > So as soon as a thread yields its CPU, it’s guaranteed to be out of its critical section. Therefore, the yielding can be seen as a blockin
by amelius 11y ago
From the article:
> So as soon as a thread yields its CPU, it’s guaranteed to be out of its critical section.
Therefore, the yielding can be seen as a blocking operation, meaning that readers do in fact block!
- gpderetta 11y agoyielding per-se is not a blocking operation, otherwise no algorithm would be non-blocking would under preemptive scheduling. It could be considered a potentially blocking operation if scheduling is exclusively cooperative.
- amelius 11y agoThe CPU is a resource too, for which there is contention just as for other resources such as files. Therefore, at every machine instruction, you are implictly performing a potentially blocking operation. (In a pre-emptive environment.) Unless you are in a critical section (in which your thread has exclusive control of the CPU). So the blocking may start again at the end of the section. I hope this makes it clear.
- gpderetta 11y agoAny scheduler worth anything guarantees forward progress which makes preemption very different from actual blocking.
- mtanski 11y agoOn Linux you can guarantee (with some effort) that your process / thread will be the only thing running on a core. There's a boot parameter that will let you black list CPUs on which to not schedule anything (by default). Then you use tasksel to schedule your process there as well. Finally, you can configure IRQ affinity so also doesn't handle interrupts on that core. It's not a 100% non pre-emptive but pretty close. I believe there was work being to enable it to be even more accurately 100 but I haven't followed along.