Perhaps I am missing something, but I don't see discussion of how an 
element is freed and how that interacts with the "index".

This might be thought not to be a "queue" in that elements are not linked 
together, but that is OK since the definition of a queue does not require 
that, only that access be first in first out.

Your starting point: the "memory chunk" contains n entries, each 
(supposedly) associated with an "index" (0 to n-1).

I don't know just when the "index" is incremented, and it is not clear 
what "appends" means within "it always appends to the next  entry by 
incrementing the ordinal number using compare and swap"
means.

Perhaps elements are never freed but it is safe to reuse them?

Without seeing the exact protocol you are proposing, it is unlikely that 
one could answer your question with confidence.
It might be necessary to use a lock or ENQ, it might be OK to use 
transactional execution, it might be OK to use CDS (if this is a true 
"free queue" then CDS logic with a sequence number is usually needed), it 
might be OK to use CS.

If elements can be freed at random times, it won't be the case that a free 
element is locatable based on the value of the "index".

Peter Relson
z/OS Core Technology Design

Reply via email to