Dismiss
InnovationQ will be updated on Sunday, Oct. 22, from 10am ET - noon. You may experience brief service interruptions during that time.
Browse Prior Art Database

Storing Variable Length Data in a Circular Buffer

IP.com Disclosure Number: IPCOM000104210D
Original Publication Date: 1993-Mar-01
Included in the Prior Art Database: 2005-Mar-18
Document File: 4 page(s) / 104K

Publishing Venue

IBM

Related People

Carlson, WC: AUTHOR [+2]

Abstract

A method of storing variable-length program trace data in a circular buffer is described. The time required to store the data is minimized, while the extraction time is considered to be non-critial.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 49% of the total text.

Storing Variable Length Data in a Circular Buffer

      A method of storing variable-length program trace data in a
circular buffer is described.  The time required to store the data is
minimized, while the extraction time is considered to be non-critial.

      Storing Data - Variable-length data packets are to be stored in
a circular buffer.  The circular buffer is a contiguous extent of
memory organized so that data is written in segments (packets)
beginning at one end, continuing towards the other end, and when the
end is reached, "wrapped" around to begin again at the original
starting point.

      A single pointer is maintained to keep track of the last byte
that has been written within the buffer.

      When a data packet is to be written to the buffer, the data
itself is copied into the buffer.  A representation of the length of
the packet is then written as a fixed-length field in the buffer.
The write pointer is then updated.  This process is repeated for each
packet recorded.

      Extracting Data - When data is to be read out of the buffer,
the writing process is disabled so the extraction process doesn't
have to deal with changing data.  This is acceptable in the original
application, as the buffer is normally read out after occurrence of
an error and performance is not critical at this time in the
application.  This step may be removed, however.  See "Variations"
for further information.

      The packets are extracted in the reverse order from which they
had been written.  The write pointer is copied to the read pointer.
The length of the last packet is taken from the location indicated by
the read pointer.  The specified number of bytes of packet data are
copied to an output buffer or file (perhaps with some formatting).

      The read pointer is then updated to point to the previous
length field by subtracting the sum of the packet length and length
information fixed length from the current read pointer value.  This
adjustment must also allow for wrapping around the buffer origin.  If
the buffer has not wrapped since system initialization, the
extraction process is stopped when the read pointer reaches the
buffer origin.  Otherwise, the process continues until the read
pointer reaches or passes the write pointer.  If the read pointer
passes the write pointer, the data that was just extracted from the
buffer has been partially overwritten, so it is discarded.

      Information on buffer wrap may be maintained with a flag or by
writing a special value at the end of the buffer.  By initializing a
zero-length packet at the end of the buffer and discarding attempts
to write other zero-length packets, the extraction process detects
that wrapping has not occurred by reaching such a packet.

      When the extraction process is complete, the writing process is
reenabled and system operation continues.

KEY FEATURES

      *    Single Write Pointer - A single pointer is ma...