On 2019-07-30, at 10:19:34, Gary Weinhold wrote:
> 
> After loading the new index value, check if it's 256.  If so, do a
> compare and swap for 255 to 0; if another process beat you to it, CS
> fails and you have to reload the index value you now want (like 0 to 1),
> just like you would if compare and swap fails.  The check for new index
> = 255 has to be done in every loop.
> 
> Or, it more be more efficient to do as was suggested in another answer:
> after loading the new index value, aNd the register with '000000FF'.
> 
> This may not be sufficient to protect the data being maintained in the
> circular queue.  If my instance acquires index 42, for example, with the
> above CS logic, there may be nothing to ensure that my instance actually
> get the CPU cycles to move data to the associated 64-bit address before
> the index is cycled by higher priority processes and some other instance
> acquires index 42.
>  
+1

... if the producer does the CS first, there's no hazard two instances'
acquiring "42"; rather the hazard is that a consumer will fetch the data
before the producer finishes moving it in.

Surely, the problem of managing a FIFO queue, whether with a circular
buffer or otherwise, has been posed and solved numerous times.  There
must be a published solution available.

Are there new z Series instructions to facilitate this?  Perhaps PLO?

-- gil

Reply via email to