Lock-free asynchronous buffer
AssigneeRaytheon Company
InventorsLloyd J. Lewins, Jeremy Edwards
Life of this patent
Estimating the term…
Abstract
A system for sharing data between two processes implements a memory arranged as a two dimensional ping/pong buffer where a writing operation alternately swaps buffers in one dimension and a reading operation swaps buffers in the other dimension. Accordingly, writing is into one or the other of a reading buffer set not currently being read with each write alternating between the write buffers. Data is retrieved from the buffer that is not currently being written. The buffer switching is coordinated by using commonly accessed variables between the reader and the writer and implements a system that is lock-free.
Claims20
A method, implemented in a computer, of accessing a memory device, the computer comprising a processor and a tangible computer-readable medium storing a plurality of instructions executable by the processor to implement the method, the method comprising:
- defining a plurality of memory buffers in the memory device, each memory buffer identified by MemBuff(X, Y) where each of X and Y is only either a first value or a different second value;
- maintaining a current pingPong variable PPC configured to flip between the first value and the second value;
- maintaining a current Index IC=(XC, YC) where each of XC and YC is configured to flip between the first value and the second value;
- and
- writing data to the memory device by:
- retrieving the current pingPong variable PPC and current Index variable IC=(XC, YC);
- writing data to a memory buffer MemBuff(XC, PPC);
- and
- when writing to the memory buffer MemBuff(XC, PPC) is complete:
- flipping the XC value in the Index IC to the other of the first value or the second value and setting YC=PPC.
A tangible computer-readable medium storing instructions thereon that when executed within a computer system causes the computer system to implement a method of accessing a memory device, the method comprising:
- defining a plurality of memory buffers in the memory device, each memory buffer identified by MemBuff(X, Y) where each of X and Y is only either a first value or a different second value;
- maintaining a current pingPong variable PPC configured to flip between the first value and the second value;
- maintaining a current Index IC =(XC, YC) where each of XC and YC is configured to flip between the first value and the second value;
- and
- writing data to the memory device by:
- retrieving the current pingPong variable PPC and current Index variable IC=(XC, YC);
- writing data to a memory buffer MemBuff(XC, PPC);
- and
- when writing to the memory buffer MemBuff(XC, PPC) is complete:
- flipping the XC value in the Index IC to the other of the first value or the second value and setting YC=PPC.
A system comprising a processor and logic stored in non-transitory, computer-readable, tangible media in operable communication with the processor, the logic configured to store a plurality of instructions that, when executed by the processor, causes the processor to implement a method of accessing a memory device, the method comprising:
- defining a plurality of memory buffers in the memory device, each memory buffer identified by MemBuff(X, Y) where each of X and Y is only either a first value or a different second value;
- maintaining a current pingPong variable PPC configured to flip between the first value and the second value;
- maintaining a current Index IC =(XC, YC) where each of XC and YC is configured to flip between the first value and the second value;
- and
- writing data to the memory device by:
- retrieving the current pingPong variable PPC and current Index variable IC=(XC, YC);
- writing data to a memory buffer MemBuff(XC, PPC);
- and
- when writing to the memory buffer MemBuff(XC, PPC) is complete:
- flipping the XC value in the Index IC to the other of the first value or the second value and setting YC=PPC.
Dependencies are inferred from the claim text.