# US 2023/0054884 A1 · Data read-write method and apparatus and circular queue

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2023/0054884 A1
- Document ID: US20230054884A1
- Status: Published application
- Kind: A1
- Application number: 18/046,364
- Filed: 2022-10-13
- Published: 2023-02-23
- Earliest claimed: 2018-05-28
- Assignees: Autel Robotics Co., Ltd.
- Applicants: Autel Robotics Co., Ltd.
- Inventors: Zhaozao LI
- Web page: https://patentgrep.com/patent/US20230054884A1

## CPC

- G06F 3/0659: {Command handling arrangements, e.g. command buffers, queues, command scheduling}
- G06F 9/5016: {the resource being the memory}
- G06F 3/0604: {Improving or facilitating administration, e.g. storage management}
- G06F 3/0679: {Non-volatile semiconductor memory device, e.g. flash memory, one time programmable memory [OTP]}
- G06F 9/544: {Buffers; Shared memory; Pipes}
- G06F 9/546: {Message passing systems or structures, e.g. queues}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## 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.

## Claims

### Claim 1

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.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the obtaining an offset position of a write pointer from a queue head of a circular queue comprises:
obtaining, through at least two read threads, the offset position of the write pointer from the queue head of the circular queue;
the at least two read threads belong to a process;
each of the at least two read threads belong to a process;
each of the at least two read threads are performed by the processor.

### Claim 3 (depends on 1)

The method according to claim 1, wherein after the reading data from the circular queue, the method further comprises:
determining whether the offset position of the write pointer in the queue head of the circular queue is updated; and
reading, in response to the offset position is updated, data from the circular queue again according to an updated offset position of the write pointer.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the determining whether the offset position of the write pointer in the queue head of the circular queue is updated comprises:
determining whether a frame number corresponding to the write pointer in the queue head of the circular queue is updated; and
determining, in response to the frame number is updated, that the offset position of the write pointer is updated.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the determining whether a frame number corresponding to the write pointer in the queue head of the circular queue is updated comprises:
updating a frame number corresponding to the read pointer;
obtaining the frame number corresponding to the write pointer in the queue head of the circular queue;
determining whether an updated frame number corresponding to the read pointer is less than the frame number corresponding to the write pointer; and
determining, in response to the updated frame number corresponding to the read pointer is less than the frame number corresponding to the write pointer, that the frame number corresponding to the write pointer in the queue head of the circular queue is updated.

### Claim 6 (depends on 5)

The method according to claim 5, wherein the determining whether the offset position of the write pointer in the queue head of the circular queue is updated comprises:
determining whether the offset position of the write pointer that is obtained again is the same as the offset position of the write pointer that is obtained previously; and
determining, in response to 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, that the offset position of the write pointer in the queue head of the circular queue is updated.

### Claim 7

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.

### Claim 8 (depends on 7)

The method according to claim 7, wherein the method further comprises:
writing the to-be-written data to the circular queue according to the offset position of the write pointer when the size sum of the offset position of the write pointer and the frame header and frame data of the frame corresponding to the to-be-written data is less than the total size of the circular queue.

### Claim 9 (depends on 8)

The method according to claim 8, wherein the determining whether the circular queue is full according to a size of the offset position of the write pointer and a size of the to-be-written data comprises:
determining whether 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;
determining, in response to the size sum is greater than or equal to the total size, that the circular queue is full; and
determining, in response to the size sum is less than the total size, that the circular queue is not full.

### Claim 10 (depends on 7)

The method according to claim 7, wherein the writing the to-be-written data to the circular queue according to the offset position of the write pointer comprises:
determining a frame of storage space in the circular queue according to the offset position of the write pointer; and
writing related information of the to-be-written data to a frame header of the storage space, and writing the to-be-written data to frame data of the storage space;
the related information of the to-be-written data comprising a total length of a to-be-written data frame.

### Claim 11 (depends on 7)

The method according to claim 7, wherein after the writing the to-be-written data to the circular queue according to the offset position of the write pointer, the method further comprises:
updating a frame number corresponding to the write pointer in the queue head.

### Claim 12

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.

### Claim 13 (depends on 12)

The apparatus according to claim 12, wherein the processor is further configured to:
obtain, through at least two read threads, the offset position of the write pointer from the queue head of the circular queue;
the at least two read threads belong to a process;
each of the at least two read threads belong to a process;
perform each of the at least two read threads.

### Claim 14 (depends on 12)

The apparatus according to claim 12, wherein the processor is further configured to:
determine whether the offset position of the write pointer in the queue head of the circular queue is updated; and
read, in response to the offset position is updated, data from the circular queue again according to an updated offset position of the write pointer.

### Claim 15 (depends on 14)

The apparatus according to claim 14, wherein the processor is further configured to:
determine whether a frame number corresponding to the write pointer in the queue head of the circular queue is updated; and
determine, in response to the frame number is updated, that the offset position of the write pointer is updated.

### Claim 16 (depends on 15)

The apparatus according to claim 15, wherein the processor is further configured to:
update a frame number corresponding to the read pointer;
obtain the frame number corresponding to the write pointer in the queue head of the circular queue;
determine whether an updated frame number corresponding to the read pointer is less than the frame number corresponding to the write pointer; and
determine, in response to the updated frame number corresponding to the read pointer is less than the frame number corresponding to the write pointer, that the frame number corresponding to the write pointer in the queue head of the circular queue is updated.

### Claim 17 (depends on 16)

The apparatus according to claim 16, wherein the processor is further configured to:
determine whether the offset position of the write pointer that is obtained again is the same as the offset position of the write pointer that is obtained previously; and
determine, in response to 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, that the offset position of the write pointer in the queue head of the circular queue is updated.

### Claim 18

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.

### Claim 19 (depends on 18)

The apparatus according to claim 18, wherein the processor is further configured to:
write the to-be-written data to the circular queue according to the offset position of the write pointer when the size sum of the offset position of the write pointer and the frame header and frame data of the frame corresponding to the to-be-written data is less than the total size of the circular queue.

### Claim 20 (depends on 19)

The apparatus according to claim 19, wherein the processor is further configured to:
determine whether 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;
determine, in response to the size sum is greater than or equal to the total size, that the circular queue is full; and
determine, in response to the size sum is less than the total size, that the circular queue is not full.
