简体   繁体   中英

Unbounded and wait-free?

This is the description of the documentation of ConcurrentLinkedQueue :

An unbounded thread-safe queue based on linked nodes. This queue orders elements FIFO (first-in-first-out).
...
This implementation employs an efficient "wait-free" algorithm

Is it possible to be unbounded and wait-free ?
I am pretty sure wait-freedom ensures a bound on any operation.

I am pretty sure wait-freedom ensures a bound on any operation.

A bound on the time (or number of instructions, or whatever) taken by the operation.

In that JavaDoc, "Unbounded" probably refers to the number of elements the queue may contain.

For instance, the JavaDoc for LinkedBlockingDeque writes :

An optionally-bounded blocking deque based on linked nodes.

The optional capacity bound constructor argument serves as a way to prevent excessive expansion. The capacity, if unspecified, is equal to Integer.MAX_VALUE. Linked nodes are dynamically created upon each insertion unless this would bring the deque above capacity.

Wait-freedom really just implies within some finite number of steps an operation will complete as explained

An algorithm is wait-free if every operation has a bound on the number of steps the algorithm will take before the operation completes

This definition doesn't apply to the ConcurrentLinkedQueue . When polling (or putting) a queue, each thread has the likelihood of failing an infinite number of times. This fact alone tells us that the queue is not truly wait free. I believe the author isn't using the definition of wait-free from Herlihy in The Art of Multiprocessor Programming.

For more information, the CLQ uses a Michael & Scott alogrithm that is explained here

Edit: Just realised the link I gave for the M and S queue is also in the API. Either should be fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM