Lock-free queues totally suck since they have to
be polled. The only lock-free structure that is
useful is a lock-free stack for pooing objects and
handling back items to a thread like with modern
memory-allocators.
Typically, polling a lock-free queue works best when
the queue nearly always has entries, a blocking queue
works best when the queue is nearly always empty.
A downside of blocking queues is latency, typically of
the order of 2-20 uS, due to kernel signaling. This can
be mitigated by designing the system so that the work done
by the consumer threads on each queued item takes much
longer than this interval.The downside of non-blocking queues
is the waste of CPU and memory bandwidth while polling an
empty queue. This can be mitigated by designing the system
so that the queue is rarely empty.
Forget it - no one wants to poll a queue. Having limited
polling with spinning for a while is the best of both sides.
You have to understand that lockfree has advantages
and disadvantages, so since lock-free queue works best
when the queue nearly always has entries, so it is used best
on those kind of situations, and for you wanting to have
limited polling with spinning for a while.., i think you
have to understand that lockfree comes with a number of
advantages like it is not prone to deadlock and it is
Pre-emption tolerant (so it is good at convoy-avoidance) etc.
so you have to take into account those factors too so that to
make a good choice depending > on the situation or the context.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 483 |
Nodes: | 16 (2 / 14) |
Uptime: | 181:47:28 |
Calls: | 9,599 |
Calls today: | 5 |
Files: | 13,679 |
Messages: | 6,151,011 |
Posted today: | 1 |