Hacker News new | ask | show | jobs
by jacquesm 2380 days ago
> If possible, avoid headaches by just not fiddling around with thread priorities.

No, learn the ins and outs of the primitives of your OS. Threads are perfectly fine to run at different priorities but as soon as you start communicating between them they become a chain of sorts and if resources are exhausted (such as a queue reaching a maximum size) or if you artificially couple the threads using some kind of sync mechanism then your priorities will not what you want them to be.

Prioritization works well for independent threads, not for dependent threads, which are somewhat closer to co-routines that happen to use the thread scheduler rather than that they call each other directly.

1 comments

The PI the article describes does not need an exhausted queue, just merely used.
That's because that particular queue is not implemented lock-free. If it were you'd have to exhaust it first.