Data read-write method and apparatus and circular queue
AssigneeAutel Robotics Co., Ltd.
InventorZhaozao LI
Life of this patent
Estimating the term…
Abstract
The present invention provides a data read-write method and apparatus and a circular queue. The method includes: obtaining an offset position of a write pointer from a queue head of a circular queue; determining an offset position of a read pointer according to the offset position of the write pointer; and reading data from the circular queue according to the offset position of the read pointer. Single input multiple output of share memory is implemented, and therefore a plurality of read threads may read data from the circular queue in parallel, thereby effectively improving read-write efficiency of data, and reducing memory consumption.
Claims20
A data read-write method, comprising:
- obtaining an offset position of a write pointer from a queue head of a circular queue;
- determining an offset position of a read pointer according to the offset position of the write pointer;
- and
- obtaining an offset position of a write pointer from a queue head of a circular queue again after reading data from the circular queue according to the offset position of the read pointer;
- reading, when the offset position of the write pointer that is obtained again is different from the offset position of the write pointer that is obtained previously, the data from the circular queue again according to an updated offset position of the write pointer.
A data read-write method, comprising:
- obtaining, when a frame of to-be-written data is obtained, an offset position of a write pointer from a queue head of a circular queue;
- changing the offset position of the write pointer to a position at which a first storage space of the circular queue is located when a size sum of the offset position of the write pointer and a frame header and frame data of a frame corresponding to the to-be-written data is greater than or equal to a total size of the circular queue;
- writing the to-be-written data to the circular queue according to the changed offset position of the write pointer;
- updating the offset position of the write pointer in the queue head.
A data reading apparatus, comprising:
- a memory, configured to store read threads;
- and
- a processor coupled to the memory, configured to call the read threads stored in the memory, to perform the following operations:
- obtaining an offset position of a write pointer from a queue head of a circular queue;
- determining an offset position of a read pointer according to the offset position of the write pointer;
- and
- obtaining an offset position of a write pointer from a queue head of a circular queue again after reading data from the circular queue according to the offset position of the read pointer;
- reading, when the offset position of the write pointer that is obtained again is different from the offset position of the write pointer that is obtained previously, the data from the circular queue again according to an updated offset position of the write pointer.
A data writing apparatus, comprising:
- a memory, configured to store write threads;
- and
- a processor coupled to the memory, configured to call the write threads stored in the memory, to perform the following operations:
- obtaining, when a frame of to-be-written data is obtained, an offset position of a write pointer from a queue head of a circular queue;
- changing the offset position of the write pointer to a position at which a first storage space of the circular queue is located when a size sum of the offset position of the write pointer and a frame header and frame data of a frame corresponding to the to-be-written data is greater than or equal to a total size of the circular queue;
- writing the to-be-written data to the circular queue according to the changed offset position of the write pointer;
- updating the offset position of the write pointer in the queue head.
Dependencies are inferred from the claim text.