Processing Ring Buffer Updates

By introducing metadata storage and atomic operation management slot acquisition and release in ring buffers, throughput bottlenecks and latency issues in multi-actioner systems are solved, and efficient non-blocking data processing is achieved.

CN113614698BActive Publication Date: 2025-07-25ARM LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202080021050.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-03-01
Filing Date
2020-02-25
Publication Date
2025-07-25
Estimated Expiration
2040-02-25

AI Technical Summary

Technical Problem

In data processing systems where multiple producers and consumers interact with ring buffers, the prior art has problems of throughput bottlenecks, nondeterministic latency and scalability, especially because producers or consumers prevent other actors from interacting with ring buffers, resulting in single-threaded bottlenecks and serialization problems.

Method used

Using a ring buffer metadata storage circuit, including the first and second reference indicators, manages the acquisition and release process of the slot through atomic operations, allowing independent actors to update the metadata in disorder to release the slot, and reduces snooping delays using atomic memory operations to achieve non-blocking ring buffer release.

Benefits of technology

It improves the scalability and throughput of the system, reduces the delay and serialization between threads, ensures that the ordering of data item sequences is not affected, and realizes disordered interactions between multiple actors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113614698B_ABST
    Figure CN113614698B_ABST
Patent Text Reader

Abstract

A ring buffer storage circuit is disclosed. The ring buffer storage circuit stores a ring buffer including a plurality of slots to maintain a queuing sequence of data items. A data processing circuit performs a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing. Each process is arranged to perform an acquisition process to acquire at least one slot in the ring buffer and subsequently perform a release process to release the at least one slot. A ring buffer metadata storage circuit stores metadata of the ring buffer, the metadata including a first reference indicator and a second reference indicator. The first reference indicator includes a current slot indicator indicating the position of a current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the ring buffer. The second reference indicator includes an expected slot indicator indicating the expected position of the current slot, where one or more pending slots have been acquired after the current slot. The release process includes attempting to update the first reference indicator of the ring buffer, including an atomic operation in which the expected slot indicator is compared with the current slot indicator. When the current slot indicator matches the expected slot indicator, at least the current slot indicator is updated by modifying the value of the current slot indicator to a predetermined value. When the current slot indicator does not match the expected slot indicator, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the ring buffer without updating the current slot indicator. A corresponding method and usage instructions are also disclosed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to data processing. More specifically, this disclosure relates to the management of a circular buffer in a data processing device. Background Art

[0002] Various data processing contexts can generate data items to be further processed in a specific order, and a mechanism for managing them is used to keep those generated data items in a queuing sequence in a circular buffer, where newly generated data items are added to the end of the queuing sequence, and data items are removed from the head of the queuing sequence for further processing. The queuing sequence of data items held in the circular buffer can provide a centralized storage of the generated data items that need further processing. Multiple "producers" operating in a data processing system can add the generated data items to this centralized storage, and multiple "consumers" in the data processing system can remove data items from this centralized storage for further processing. However, this interaction of multiple producers and consumers with the circular buffer can mean that an action of one producer or consumer with respect to the content of the circular buffer can prevent other producers or consumers from performing their own interaction with the circular buffer. In a lock-based approach, only one producer or consumer can access the circular buffer at a time, and thus this can become a significant bottleneck in throughput. Additionally, even in a "lock-free" circular buffer design, one producer or consumer can still prevent other producers or consumers from completing, due to the constraint that it must release its updates to the circular buffer in the order in which the circular buffer is acquired (i.e., in the order of the queuing sequence of data items) in order to preserve the correct ordering of the circular buffer and the updates made to it. If an earlier producer or consumer stops (e.g., in an interaction with another system component, such as a cache memory miss or being preempted by the operating system), then a later producer or consumer must wait until the earlier producer or consumer completes. This creates non-determinism (delays and stalls in one thread can propagate to other threads) and also creates scalability issues (since multiple threads are effectively passing symbolic tokens between them to complete, and this creates serialization of all the threads involved). Conversely, designating a single thread for processing reordered results can potentially lead to a single-thread bottleneck. Summary of the Invention

[0003] In an exemplary embodiment, there is a device that includes: a ring buffer storage circuit for storing a ring buffer including a plurality of slots to maintain a queuing sequence of data items; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the ring buffer and subsequently perform a release process to release the at least one slot; and a ring buffer metadata storage circuit for storing metadata of the ring buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the ring buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, one or more pending slots having been acquired after the current slot, wherein when the process performs the acquisition process to acquire at least one slot in the ring buffer, the expected slot value is the value of the expected slot indicator, wherein the release process includes an attempt to update the first reference indicator of the ring buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, at least the current slot indicator is updated by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the ring buffer without updating the current slot indicator.

[0004] In another exemplary embodiment, there is a method of operating a data processing apparatus, the method comprising the steps of: allocating storage for a ring buffer including a plurality of slots to hold a queuing sequence of data items; performing a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing, wherein a fetch process is performed to fetch at least one slot in the ring buffer and subsequently a release process is performed to release the at least one slot; allocating storage for metadata of the ring buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the ring buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, one or more pending slots having been fetched after the current slot, wherein when the process performs the fetch process to fetch at least one slot in the ring buffer, the expected slot value is the value of the expected slot indicator, wherein the release process includes an attempt to update the first reference indicator of the ring buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, at least the current slot indicator is updated by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the ring buffer without updating the current slot indicator.

[0005] In another exemplary embodiment, there is a device that includes: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to maintain a queuing sequence of data items; an instruction decoder circuit for decoding instructions; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, where each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and subsequently perform a release process to release the at least one slot; and a circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, one or more pending slots having been acquired after the current slot, where when the process performs the acquisition process to acquire at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, where the instruction decoder circuit responds to a circular buffer release instruction to be executed by the data processing circuit to control the data processing circuit to perform the release process, the release process including the steps of: attempting to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, updating at least the current slot indicator by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, updating the pending slot indicator by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the circular buffer without updating the current slot indicator.

[0006] In another exemplary embodiment, there is a computer program for controlling a host data processing device to provide an instruction execution environment, and comprising: ring buffer storage logic for storing a ring buffer including a plurality of slots to hold a queuing sequence of data items; instruction decoder logic for decoding instructions; data processing logic for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the ring buffer and subsequently perform a release process to release the at least one slot; and ring buffer metadata storage logic for storing metadata of the ring buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the ring buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, one or more pending slots having been acquired after the current slot, wherein when the process performs the acquisition process to acquire at least one slot in the ring buffer, the expected slot value is the value of the expected slot indicator, wherein the instruction decoder logic responds to a ring buffer release instruction to be executed by the data processing logic to control the data processing logic to perform the release process, the release process including the steps of: attempting to update the first reference indicator of the ring buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, updating at least the current slot indicator by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, updating the pending slot indicator by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the ring buffer without updating the current slot indicator.

[0007] In another exemplary embodiment, there is a device that includes: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to maintain a queuing sequence of data items; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer; and a circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot at one end of the data item queuing sequence, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot at the other end of the data item queuing sequence, wherein this end of the data item queuing sequence is the head end or the tail end of the data item queuing sequence, wherein the acquisition process includes an attempt to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, the expected slot indicator is updated by modifying the value of the expected slot indicator.

[0008] In another exemplary embodiment, there is a method of operating a data processing device, the method including the steps of: allocating storage for a circular buffer including a plurality of slots to maintain a queuing sequence of data items; performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein an acquisition process is performed to acquire at least one slot in the circular buffer; allocating storage for metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot at one end of the data item queuing sequence, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot at the other end of the data item queuing sequence, wherein this end of the data item queuing sequence is the head end or the tail end of the data item queuing sequence, wherein the acquisition process includes an attempt to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, the expected slot indicator is updated by modifying the value of the expected slot indicator.

[0009] In another exemplary embodiment, there is a device that includes: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to maintain a queuing sequence of data items; an instruction decoder circuit for decoding instructions; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer; and a circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot at one end of the data item queuing sequence, and the second reference indicator including an expected slot indicator indicating the expected position of a current slot at the other end of the data item queuing sequence, wherein this end of the data item queuing sequence is the head end or the tail end of the data item queuing sequence, wherein the instruction decoder circuit responds to a circular buffer acquisition instruction to be executed by the data processing circuit to control the data processing circuit to perform the acquisition process, the acquisition process including the steps of: attempting to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, updating the expected slot indicator by modifying the value of the expected slot indicator.

[0010] In another exemplary embodiment, there is a computer program for controlling a host data processing device to provide an instruction execution environment and including: ring buffer storage logic for storing a ring buffer including a plurality of slots to hold a queuing sequence of data items; instruction decoder logic for decoding instructions; data processing logic for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the ring buffer; and ring buffer metadata storage logic for storing metadata of the ring buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot at one end of the data item queuing sequence, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot at the other end of the data item queuing sequence, wherein this end of the data item queuing sequence is the head end or the tail end of the data item queuing sequence, wherein the instruction decoder logic responds to a ring buffer acquisition instruction to be executed by the data processing logic to control the data processing logic to perform the acquisition process, the acquisition process including the steps of: attempting to update the second reference indicator of the ring buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the ring buffer are eligible for acquisition, updating the expected slot indicator by modifying the value of the expected slot indicator. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Embodiments of the present technology will be further described by way of example only with reference to the drawings as shown, and these embodiments will be read in conjunction with the following description, wherein:

[0012] Figure 1 Schematically shows a data processing device according to an embodiment of the present disclosure;

[0013] Figure 2 Schematically shows a ring buffer according to an embodiment of the present disclosure and adding and removing data items from the ring buffer by a producer and a consumer referring to a head pointer and a tail pointer;

[0014] Figure 3 Schematically shows how a producer may be blocked from releasing its update because a previous producer has not completed the release of its update;

[0015] Figure 4aShows ring buffer metadata including a first reference indicator and a second reference indicator according to an embodiment of the present disclosure;

[0016] Figure 4b Shows ring buffer metadata for tracking the tail end of a data item queuing sequence according to an embodiment of the present disclosure;

[0017] Figure 4c Shows ring buffer metadata for tracking the head end of a data item queuing sequence according to an embodiment of the present disclosure;

[0018] Figure 5 Shows ring buffer metadata according to an embodiment of the present disclosure;

[0019] Figure 6 Shows a sequence of steps taken in a method of an embodiment when a system component performs an atomic acquire operation;

[0020] Figure 7 Shows a sequence of steps taken when a system component attempts to update the second reference indicator of the present technology;

[0021] Figure 8 Shows a sequence of steps taken in a method of an embodiment when a system component performs an atomic release operation;

[0022] Figure 9 Shows a sequence of steps taken when a system component attempts to update the first reference indicator of the present technology;

[0023] Figure 10 Schematically shows a data processing device according to an embodiment of the present disclosure; and

[0024] Figure 11 Schematically shows components of a system that provides simulator implementation in one embodiment. Detailed Description

[0025] At least some embodiments provide an apparatus that includes: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to maintain a queuing sequence of data items; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and subsequently perform a release process to release the at least one slot; and a circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, one or more pending slots having been acquired after the current slot, wherein when the process performs the acquisition process to acquire at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, wherein the release process includes an attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, at least the current slot indicator is updated by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the circular buffer without updating the current slot indicator.

[0026] This technology recognizes that in a data processing system using a circular buffer as a queuing sequence, multiple independent actors (e.g., threads) add data items to be processed to the queuing sequence (i.e., are "producers") and remove data items from the queuing sequence for processing (i.e., are "consumers"), and unless these actors operate only in a strictly sequential manner with respect to the order in which the data item sequence must be processed (which would lead to significant scalability issues if more and more actors are allowed to interact with the circular buffer), in order to allow scalability, the actors need to be able to release their updates out of order.

[0027] Generally speaking, there are 3-step enqueue operations for adding data items to be processed to the end of a queuing sequence and 3-step dequeue operations for removing data items from the head of the queuing sequence for further processing. The 3-step enqueue operation is performed by the following operations: first, obtaining slots (or multiple slots) in a circular buffer, second, writing an element to the obtained slot, and third, releasing the obtained slot. Similarly, the 3-step dequeue operation is performed by the following operations: first, obtaining slots (or multiple slots) in a circular buffer, second, reading an element from the obtained slot, and third, releasing the obtained slot. This is a relatively simple process in a system with a single producer and a single consumer, and is naturally lock-free in this case. However, in the case of a system including multiple producers and multiple consumers, the enqueue and dequeue operations require synchronization between independent actors that interact with the circular buffer. Specifically, in the case where multiple producers (or consumers) each interact with the circular buffer to add (or remove) one or more data items at the end (or head) of the queuing sequence, each producer (or consumer) attempts to obtain a given number of slots at the end (or head) of the queuing sequence and then release the obtained slots. In this way, one producer (or consumer) may prevent other producers (or consumers) from completing, due to the constraint that it must release its updates to the circular buffer in the order in which the circular buffer was obtained (i.e., in the order of the queuing sequence of data items).

[0028] This technique uses circular buffer metadata to break the interdependencies among multiple independent actors, allowing the multiple independent actors to execute in parallel and release their updates in an unordered manner relative to the order of the queuing sequence while preserving the order of the data item sequence. To this end, this technique provides circular buffer metadata including a first reference indicator and a second reference indicator that can be accessed through atomic operations. Multiple independent actors can each update the circular buffer metadata in an unordered manner such that each actor can cause a change in the metadata to mark its update for later release. Thus, the circular buffer metadata can be updated by an actor that has completed an enqueue operation or a dequeue operation to provide an indication of which slots in the circular buffer are pending release, such that the circular buffer metadata can then be updated in a manner that releases slots in the order in which the slots are acquired. The circular buffer metadata can allow independent actors to release their updates in order and out of order relative to the order in which the data items must be processed, thereby providing a non-blocking circular buffer release implementation. The corresponding actors can interact with the circular buffer simultaneously to release their updates and can preserve the ordering of the data item sequence by atomically updating the first reference indicator, where an actor attempting to release an update (either in order or out of order) can update the first reference indicator to modify at least one value associated with the first reference indicator such that each actor can modify the circular buffer metadata even if the actor is releasing in an unordered manner. In addition, this technique provides a circular buffer metadata storage device for storing the metadata of the circular buffer in a memory, which can be accessed by corresponding independent actors executed by a processor core through "far" atomic execution of metadata operations ("far" atomic in the sense that the atomic operation accesses data in a cache memory in the memory or the memory system that is further away from the core rather than "near" atomic that accesses data in a tightly coupled cache memory in an atomic manner). The implementation of such "far" atomic operations for performing atomic memory updates of the circular buffer metadata means that the corresponding actors can simultaneously attempt to update the circular buffer metadata in a manner that reduces the latency associated with snooping (i.e., snooping latency) because "near" accesses to the metadata that would cause an increase in snooping latency can be avoided or limited. This allows independent actors to update the circular buffer metadata to interact with the circular buffer to release updates and can reduce the latency caused by contention for the circular buffer metadata due to multiple actors attempting to access the metadata simultaneously. The implementation of such "far" atomic operations can reduce the latency associated with snooping and thus allows for a reduction in the time required to perform each metadata operation such that the metadata operations can be executed by the actors at a greater frequency, which improves scalability because more cores can operate on the circular buffer simultaneously.

[0029] The first reference indicator includes a current slot indicator indicating the position of the current slot among a plurality of slots of the circular buffer and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, where the one or more pending slots have been acquired relative to the order of the queuing sequence after the current slot. The current slot indicator indicates a position in the circular buffer that represents the current position of the end or head of the data item queuing sequence. For example, for a circular buffer including N two slots (i.e., a circular buffer having N N elements, where N is an integer), the current slot indicator can be used to provide an indication of which slot in the circular buffer corresponds to the oldest data item (at the head) or which slot in the circular buffer corresponds to the newest data item (at the tail). Thus, the current slot indicator can be a scalar value that can represent the position of any given slot in the circular buffer at a given time, depending on the position of the head or tail of the queuing sequence in the circular buffer. It should be understood that the current slot indicator can indicate the current slot position in the circular buffer by indicating the position of an empty (unused) slot available for writing or a non-empty (used) slot not available for writing but available for consumption (reading) to represent the position of the end (head or tail) of the data item queuing sequence.

[0030] In addition, the first reference indicator includes a pending slot indicator indicating the position of one or more pending slots among the plurality of slots of the circular buffer. The pending slot indicator can be updated by an actor that releases its update in an unordered manner, such that the pending slot indicator indicates the presence (possibly no pending slots) of at least one pending slot in the circular buffer and also indicates the position of at least one pending slot in the circular buffer when the pending slot is indicated as present. The pending slot indicator can be, for example, a scalar value indicating the position of the slot in the circular buffer for which an enqueue operation (head) or dequeue operation (tail) has been completed by an actor and has been released by the actor in an unordered manner and is pending release by the circular buffer.

[0031] Thus, the first reference indicator provides: an indication of the position of the current slot of the circular buffer; an indication of whether there is one or more updates that have been released out of order by an actor interacting with the circular buffer; and an indication of the position of one or more pending slots in the circular buffer corresponding to the one or more updates released out of order by an actor interacting with the circular buffer. Thus, the first reference indicator can be used, for example, as a head pointer or a tail pointer of the current slot of a data item queuing sequence, while also indicating the presence and position of one or more pending slots of the queuing sequence at the head end or the tail end, respectively. When an actor in the system wishes to release an update (to release the acquired slot after reading from or writing to the slot is completed), the metadata of the circular buffer can be accessed atomically by the actor, and the first reference indicator can be updated to allow the actor to release the update by updating the current slot indicator or the pending slot indicator of the first reference indicator. Thus, the first reference indicator can be updated by an actor that releases its updates in order relative to the order of the data item queuing sequence and also by an actor that releases its updates out of order relative to the order of the data item queuing sequence, and thus, the actor is not limited to releasing its updates to the circular buffer in the order in which the circular buffer is acquired, and thus, a non-blocking circular buffer release implementation can be achieved.

[0032] The second reference indicator includes an expected slot indicator indicating an expected position of a current slot of the circular buffer. A given actor interacting with the circular buffer may attempt to update the second reference indicator in order to acquire one or more slots in the circular buffer for writing (producer) or reading (consumer). A producer or a consumer may wish to acquire one or more slots of the circular buffer and will attempt to update the second reference indicator to acquire one or more slots, the attempt including an atomic operation (atomic fetch operation) accessing the circular buffer metadata. For example, a producer may wish to acquire one or more slots at the tail end of a queuing sequence and will thus attempt to access the circular buffer metadata and update the second reference indicator by modifying a value associated with the second reference indicator to point to another slot such that other producers subsequently attempting to acquire one or more slots at the tail end of the queuing sequence cannot acquire the slots already acquired by the first producer. When a producer or a consumer performs a fetch process and successfully acquires one or more slots in the circular buffer, an expected slot value is returned for the producer or the consumer. When a producer or a consumer acquires one or more slots in the circular buffer, the expected slot value is the value of the expected slot indicator. Thus, the expected slot value indicating the value of the expected slot indicator when a process acquires one or more slots in the circular buffer can be maintained for the process and, when the process subsequently attempts to release one or more slots, the expected slot value can subsequently be compared with the first reference indicator. Thus, the comparison of the expected slot value of a process with the first reference indicator can provide an indication as to whether the process is attempting to release the acquired slots in an out-of-order or in-order manner relative to the order of the data item queuing sequence. In some examples, a process may successfully acquire X slots (X>1) in the circular buffer and, when the process acquires X slots, the expected slot value can provide an indication of the value of the expected slot indicator. Thus, the comparison of the expected slot value with the current slot indicator can be a range comparison, where the current slot indicator is compared with a range given by the combination of the expected slot value and the number of acquired slots. For example, if the process acquires two slots and the value of the expected slot indicator is N when the process acquires two slots, the range defined by N and the slot adjacent to the slot indicated by N can be used for comparison with the current slot indicator.

[0033] This technology recognizes that ring buffer metadata can be stored in memory and accessed by actors performing atomic operations to acquire and release slots, and that the ring buffer metadata can preserve the ordering of the queuing sequence. Although a slot can be acquired by accessing and updating a second reference indicator, the order in which an actor completes and thus attempts to release its slot can be different from the order in which the slot was acquired, and the actor can thus attempt to access and update the first reference indicator in a different order than the second reference indicator was accessed and updated. When an actor successfully updates the second reference indicator, the value of the expected slot indicator is modified to indicate that the actor has acquired one or more slots in the ring buffer. An expected slot value corresponding to the value of the expected slot indicator when the actor acquired one or more slots is returned to the actor and used by the actor when attempting to release the acquired slot(s) to verify whether the actor is releasing in order or out of order (i.e., the expected slot position for the actor is based on the value of the second reference indicator when the actor acquired one or more slots). When an actor has completed writing to or reading from one or more acquired slots and attempts to release one or more acquired slots, by using the expected slot value returned to the actor when the slot was acquired, the actor can attempt to update the first reference indicator of the ring buffer by atomically accessing the ring buffer metadata and comparing the expected slot value to the current slot indicator of the first reference indicator. Thus, it should be understood that the atomic release operation includes the actor attempting to update the first reference indicator, where the actor compares the expected slot value to the first reference indicator. Specifically, the actor attempts to atomically update the first reference indicator based on a comparison of the expected slot value to the value of the current slot indicator, and the manner in which the actor updates the first reference indicator depends on whether the expected position of the current slot indicated by the expected slot value matches the position of the current slot indicated by the current slot indicator of the first reference indicator.

[0034] In some embodiments, when the current slot indicator does not match the expected slot value and the expected slot indicator does not indicate that the current slot's position relative to the queuing sequence is in the expected position after the current slot indicated by the current slot indicator, the first reference indicator is not updated.

[0035] This technique recognizes that although a process attempts to atomically access and update a first reference indicator, other processes may simultaneously attempt to atomically access and update the first reference indicator to free a slot. When the expected slot value of a process does not match the value of the current slot indicator of the first reference indicator, this indicates that the process is attempting to free a slot out of order with respect to the order of the data item queuing sequence. When the expected slot value does not match the value of the current slot indicator and the expected slot value also indicates a slot position that is not after the position of the current slot with respect to the ordering of the data item queuing sequence, this indicates that the process is not attempting to free a slot that is earlier in the ordering with respect to the sequence (the process is not attempting to free a slot earlier in the ordering with respect to the sequence). In this case, the process completes the freeing process without updating the first reference indicator because the process is attempting to free a slot that is "behind" the ordering with respect to the queuing sequence, and the freeing of the slot is already reflected in the first reference indicator.

[0036] In some embodiments, when the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots in the circular buffer relative to the current slot indicated by the current slot indicator.

[0037] This technique recognizes that when the expected slot value of a process does not match the value of the current slot indicator of the first reference indicator and the expected slot value also indicates a slot position that is after the position of the current slot with respect to the ordering of the data item queuing sequence, this indicates that the process is attempting to free a slot that is out of order and "ahead" with respect to the sequence. In other words, this indicates that the process is attempting to free a slot before another process has freed another slot in the sequence that is earlier than the slot the process is attempting to free. In this case, when performing the freeing process, the process atomically accesses the first reference indicator and updates the pending slot indicator to indicate the presence of one or more pending slots.

[0038] In some embodiments, the pending slot indicator includes a limit indicator that indicates the position of the farthest pending slot from the current slot in the circular buffer with respect to the order of the queuing sequence.

[0039] In some embodiments, the pending slot indicator includes a change indicator whose change indicates a change in the number of pending slots between the current slot and the farthest pending slot.

[0040] The present technique provides a pending slot indicator that includes an extremity indicator to indicate the position of the farthest pending slot in a circular buffer. Additionally, the pending slot indicator may include a change indicator, where a change in the change indicator indicates a change in the number of pending slots that exist between the current slot indicated by the current slot indicator and the farthest pending slot indicated by the extremity indicator. A process may free slots that are between the current slot and the farthest pending slot by changing the change indicator such that the presence of additional pending slots is indicated.

[0041] Depending on the configuration of the pending slot indicator when the process updates the pending slot indicator (e.g., whether there are one or more pending slots or whether there are no pending slots), the extremity indicator or the change indicator or both the extremity indicator and the change indicator may be updated. For example, the order of a queuing sequence may be such that slot A is followed by slot B, slot B is followed by slot C, and so on. In this case, if the current slot indicated by the current slot indicator is slot A and the process wishes to free slot D before slot B or slot C is freed, the process will update the extremity indicator to indicate the presence and position of slot D as a pending slot. In this way, the position of slot D may be indicated as the farthest pending slot. If subsequently another process wishes to free slot E, the extremity indicator may be updated to indicate the presence and position of slot E as the farthest pending slot from the current slot (slot A). In this way, the extremity indicator may be updated by processes that free updates in an unordered manner to indicate the position of the farthest pending slot.

[0042] Continuing with the above example, if the extremity indicator indicates the presence and position of slot E as the farthest pending slot from the current slot (slot A) and subsequently another process wishes to free slot C, the change indicator may be updated to indicate a change in the number of pending slots between the current slot (slot A) and the farthest pending slot (slot E). In this way, the change indicator may be updated to allow the process to free slots that are between the current slot and the farthest pending slot. A change in the change indicator thus indicates that an update has been freed for which the extremity indicator need not be updated. Accordingly, a change in the change indicator indicates a change in the number of pending slots between the current slot and the farthest pending slot. This allows the process to free updates by updating the extremity indicator or the change indicator or both, and the process may thus be free without having to wait for an earlier process to free its update. In some examples, both the extremity indicator and the change indicator are updated depending on whether the process is attempting to free a slot that is farther from the current slot and the farthest pending slot indicated by the extremity indicator, as described above. Alternatively, in some examples, the change indicator may be updated for each update that is freed such that a change in the change indicator may be used to indicate that the update has been freed by the process and the extremity indicator indicates the position of the farthest pending slot.

[0043] As described above, the update limit indicator can be updated to indicate the presence and location of slot E as the farthest outstanding slot from the current slot (slot A). When the in-order process attempts to release slot B such that the process attempts to perform the release in order relative to the order of the data item queuing sequence, the in-order process can perform a scan of the circular buffer from the current slot indicated by the current slot indicator to the farthest outstanding slot indicated by the limit indicator, such that the in-order process can release other outstanding slots between the current slot and the farthest outstanding slot. In this way, the in-order process can release slot B in order relative to the order of the queuing sequence, and the in-order process can scan the circular buffer between the current slot and the farthest outstanding slot to identify and release other slots between the current slot and the farthest outstanding slot in order relative to the order of the data item queuing sequence. The value of the change indicator before the process performs the scan of the circular buffer for outstanding updates can be used by the process to compare with the value of the change indicator after the scan of the circular buffer to identify whether one or more updates have been released out of order for which the limit indicator may not be updated. When the comparison of the old value of the change indicator (after the scan) with the new value of the indicator (before the scan) indicates that an update has been released out of order (for which the limit indicator may not be updated), the in-order process can scan the circular buffer again to identify other slots that can be released in order.

[0044] In some examples, the outstanding slot indicator can use only the change indicator without using the limit indicator. In this case, the change indicator can be updated for each slot that is released such that the change indicator is updated to indicate the change in the number of outstanding slots. The in-order process can perform a scan that starts at the current slot indicated by the current slot indicator, and the scan will end when the in-order process identifies a slot that is not an outstanding release. In this way, the in-order process can release slot B in order, scan the circular buffer for outstanding slots to release slot C as an outstanding release, and the process will stop scanning when it identifies a non-outstanding slot (e.g., a non-outstanding slot can be indicated by a null pointer).

[0045] In some embodiments, when the current slot indicator does not match the expected slot value, the outstanding slot indicator is updated by modifying at least one of the limit indicator and the change indicator.

[0046] In some embodiments, when the expected slot value indicates a slot that is farther from the current slot in the circular buffer than the farthest outstanding slot indicated by the limit indicator relative to the order of the queuing sequence, the limit indicator is updated. In some embodiments, the limit indicator is updated based on the value of the expected slot value to indicate a different location of the farthest outstanding slot.

[0047] When the pending slot indicator indicates the presence of a pending slot and the expected slot value of the process indicates a slot that is further from the current slot than the furthest pending slot currently indicated by the limit indicator, the process updates the pending slot indicator by updating the limit indicator to indicate the new furthest pending slot corresponding to the slot that the process is attempting to free. A process attempting to free slots in an unordered manner may update the limit indicator such that the limit indicator indicates another slot as the furthest pending slot. Thus, when a process attempts to free slots in order relative to the order of the data item queuing sequence, the ordered process may use the limit indicator to perform a scan to define the furthest pending slot such that the scan of the pending slots in the circular buffer is performed between the current slot and the furthest pending slot.

[0048] In some embodiments, when the expected slot value indicates a slot that is between the current slot and the furthest pending slot, the change indicator is updated without updating the limit indicator. Since the slot is closer to the current slot than the furthest pending slot, the limit indicator will not be updated and, instead, the unordered process will release its update by updating the change indicator to indicate a change in the number of pending slots between the current slot and the furthest pending slot.

[0049] When the pending slot indicator indicates the presence of a pending slot and the expected slot value of the process indicates a slot that is not further from the current slot than the furthest pending slot currently indicated by the limit indicator, the process updates the pending slot indicator by updating the change indicator to indicate the presence of additional pending slots between the current slot and the furthest pending slot without updating the limit indicator because the position of the furthest pending slot has not changed. This allows an unordered process to release its update by updating the change indicator when the slot to be freed by the process is not further from the current slot than the furthest pending slot. Thus, when another process attempts to free slots in order relative to the order of the data item queuing sequence, the ordered process may perform a scan based on the limit indicator and the change indicator to allow the release of other pending slots in order relative to the order of the data item queuing sequence. By comparing the change indicator before releasing an ordered slot with the change indicator after releasing the ordered slot, a change in the change indicator can be identified such that the process can identify whether another scan of the circular buffer is performed for one or more pending slots that have been freed between the start and end of the scan.

[0050] When there are no pending slots in the circular buffer, the limit indicator will indicate that there are no pending slots in the circular buffer. Accordingly, when a process attempts to free a single pending slot and the limit indicator has such a configuration, the process can only update the limit indicator to indicate the presence and location of the single slot freed by the process. Additionally, the process can also update the change indicator to indicate that a change has occurred. In the case where a process attempts to free multiple pending slots and the limit indicator indicates that there are no pending slots, the process will update both the limit indicator and the change indicator to indicate the presence and location of the farthest pending slot and the presence of other pending slots between the current slot and the farthest pending slot.

[0051] In some embodiments, when the current slot indicator matches the expected slot value and the pending slot indicator indicates the presence of one or more pending slots in the circular buffer, the current slot indicator is updated by modifying the value of the current slot indicator according to the number of consecutive pending slots adjacent to the current slot. When the expected slot value matches the value of the current slot indicator, this provides an indication that the process is attempting to perform the release in order relative to the order of the data item queuing sequence. In this case, the process can perform a scan of the circular buffer from the slot indicated by the current slot indicator to the farthest pending slot indicated by the limit indicator, and the pending slots adjacent to the current slot can be freed by the process. Thus, the process can free one or more slots obtained by the process and also free one or more consecutive pending slots adjacent to the current slot.

[0052] In some embodiments, the value of the current slot indicator is modified to indicate the farthest pending slot among one or more consecutive pending slots, and the farthest pending slot is the pending slot among one or more consecutive pending slots that is the farthest from the current slot in the circular buffer.

[0053] This technique allows a process to compare an expected slot value with the value of the current slot indicator of the circular buffer metadata, and when the current slot indicator matches the expected slot value, this indicates that the process is attempting to release the slot in order relative to the order of the data item queuing sequence. When attempting to release the slot in order relative to the order of the queuing sequence, the pending slot indicator can be read to provide an indication of the presence of any pending slots and, if present, their furthest position. When the pending slot indicator indicates the absence of pending slots (indicating that there are no pending slots in the circular buffer), the current slot indicator can be updated to modify the value of the current slot indicator to indicate the position of the next slot in the queuing sequence. When the pending slot indicator indicates the presence of one or more pending slots in the circular buffer, a scan of the slots in the circular buffer between the current slot and the furthest pending slot indicated by the limit indicator can be performed to identify whether there are one or more pending slots adjacent to the current slot. In the case where there are one or more pending slots adjacent to the current slot, the current slot indicator can be updated to indicate the position of the furthest pending slot furthest from the current slot, where all slots between the current slot and the furthest pending slot are pending slots. In this way, the pending slot indicator can be read and a scan of a given number of slots in the circular buffer can be performed to identify the position of each pending slot between the current slot and the slot indicated by the limit indicator, and when the system is in order, the first reference indicator can be updated based on the number of consecutive pending slots adjacent to the current slot. In the case where there are one or more pending slots but none of these pending slots are adjacent to the current slot, the current slot indicator can be updated to modify the value of the current slot indicator to indicate the position of the next slot in the queuing sequence in order to release the slot in order relative to the order of the data item queuing sequence.

[0054] In some embodiments, the current slot indicator indicates the position of the current slot at the head or tail end of the data item queuing sequence, and the expected slot indicator indicates the expected position of the current slot at the same end of the data item queuing sequence.

[0055] In some embodiments, the first reference indicator is a tail indicator for the tail end of the data item queuing sequence for the process of removing data items from the queuing sequence, and the second reference indicator is a tail indicator for the tail end of the data item queuing sequence for the process of adding data items to the queuing sequence.

[0056] In some embodiments, the process of adding a data item to the queuing sequence is arranged to perform an acquisition process to acquire at least the next empty slot in the circular buffer, the acquisition process including an attempt to update the second reference indicator according to an atomic operation.

[0057] In some embodiments, the first reference indicator is a head indicator for adding a data item to the head of a process data item queuing sequence, and the second reference indicator is a head indicator for removing a data item from the head of a process data item queuing sequence.

[0058] In some embodiments, the process of removing a data item from the queuing sequence is arranged to perform an acquisition process to acquire at least the next non-empty slot in the circular buffer, the acquisition process including attempting to update the second reference indicator according to an atomic operation.

[0059] In some embodiments, when the process performs an acquisition process to acquire at least one slot in the circular buffer, the second reference indicator is updated by modifying the value of the expected slot indicator according to the number of slots acquired by one of the processes.

[0060] In some embodiments, the data processing circuit is arranged to perform the process of adding a data item to the queuing sequence in parallel, and each process simultaneously attempts to update the first reference indicator according to an atomic operation.

[0061] In some embodiments, the data processing circuit is arranged to perform the process of removing a data item from the queuing sequence in parallel, and each process simultaneously attempts to update the first reference indicator according to an atomic operation.

[0062] At least some embodiments provide an apparatus that includes: a circular buffer storage circuit configured to store a circular buffer including a plurality of slots to maintain a queuing sequence of data items; a data processing circuit configured to perform a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer; and a circular buffer metadata storage circuit configured to store metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating a position of a current slot at one end of the data item queuing sequence, and the second reference indicator including an expected slot indicator indicating an expected position of a current slot at the other end of the data item queuing sequence, wherein this end of the data item queuing sequence is a head end or a tail end of the data item queuing sequence, wherein the acquisition process includes an attempt to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, the expected slot indicator is updated by modifying the value of the expected slot indicator. This provides an atomic acquisition operation that allows a process to atomically access and update circular buffer metadata to acquire one or more slots in the circular buffer.

[0063] In some embodiments, the first reference indicator is a tail indicator for the tail end of the data item queuing sequence for the process of removing data items from the queuing sequence, and the second reference indicator is a head indicator for the head end of the data item queuing sequence for the process of removing data items from the queuing sequence. In some embodiments, for the process of removing data items from the queuing sequence, the number of slots eligible for acquisition corresponds to the number of occupied slots in the circular buffer, and wherein the number of occupied slots in the circular buffer is determined based on the position of the current slot at the head end and the position of the current slot at the tail end. Thus, for a consumer removing data items from the queuing sequence, the index corresponding to the position of the head end can be subtracted from the index corresponding to the position of the tail end (tail - head) in order to calculate the number of occupied slots in the circular buffer.

[0064] In some embodiments, the first reference indicator is a head indicator for adding a data item to the head end of a queuing sequence of process data items, and the second reference indicator is a tail indicator for adding a data item to the tail end of a queuing sequence of process data items. In some embodiments, for the process of adding a data item to a queuing sequence, the number of slots eligible for acquisition corresponds to the number of unoccupied slots in a circular buffer, and wherein the number of unoccupied slots in the circular buffer is determined based on the total number of slots in the circular buffer, the position of the current slot at the head end, and the position of the current slot at the tail end. Thus, for a producer adding a data item to a queuing sequence, the index corresponding to the position at the tail end can be subtracted from the index corresponding to the position at the head end (tail - head) to calculate the number of occupied slots in the circular buffer, and the number of occupied slots can be subtracted from the total number of slots in the circular buffer to calculate the number of unoccupied slots in the circular buffer (i.e., circular buffer size - (tail - head) = circular buffer size + head - tail = number of unoccupied slots), where the unoccupied slots are eligible for acquisition by the producer.

[0065] Some specific embodiments will now be described with reference to the accompanying drawings.

[0066] Figure 1 A data processing apparatus 10 in one embodiment is schematically shown. The data processing apparatus 10 includes a first core 12 and a second core 14. Each of these cores is provided with its own private L1 cache memory, namely cache memory 16 and cache memory 18 respectively. A level 2 cache memory 20 is shared and leads to a memory 22. The data processing apparatus 10 is not only a multi-core system but also a multi-threaded system, which is Figure 1 illustrated by the representation of threads T0 24 and T1 26 executed on core 12 and threads T2 28 and T3 30 on core 14. In a manner familiar to those of ordinary skill in the art, a given thread executed in a given processor core performs data processing operations on data retrieved from the memory 22, and a temporary copy of the data item retrieved from the memory 22 is cached in the cache memory hierarchy formed by the relevant intermediate cache memory levels. In Figure 1Some data structures particularly relevant to some embodiments of the present technology are schematically shown in the memory 22, namely the circular buffer storage device 32 and the circular buffer metadata storage device 34. The circular buffer metadata storage device 34 corresponds to a plurality of storage locations in the memory 22 such that the circular buffer metadata can be stored at these storage locations and accessed by threads executing on the kernel. Thus, the data structures of the circular buffer metadata stored at the storage locations in the memory 22 can be accessed atomically by the threads T0, T1, T2, and T3 executing on the kernels 13 and 14. The present technology will be further explained with reference to these data structures in the following figures.

[0067] Figure 2 Schematically represents a circular buffer 50 wound in a manner familiar to those of ordinary skill in the art. The circular buffer 50 stored in the circular buffer storage device 32 and thus logically stored in Figure 1 the memory 22 shown is used by processes executing on the kernels 12 and 14 to coordinate the processing of specific data items. Generally speaking, the use of the circular buffer can be observed from two aspects. First, those of one or more "producers" in the system, which generate data items stored in the circular buffer 50, and second, those of the "consumers", which remove data items from the circular buffer 50 for further data processing. The key feature of the circular buffer is that it is arranged such that the data items held in the circular buffer are in a queued (ordered) sequence, such that the order in which the producer generates the data items is also the order in which they are consumed by the consumer. The general principle according to which this is achieved is that the next data item (represented by the shaded slot in Figure 2 ) generated by the producer (see item 52 in Figure 2 ) is enqueued at the "tail" of the stored sequence, while the oldest data item still in the sequence dequeues from its head for consumer processing (see item 54 in Figure 2 ). In other words, the data item at the head of the queued sequence is the oldest data item, and the data item at the tail of the queued sequence is the newest data item. To track the current state of the valid data items in the circular buffer, the system stores four pointers, two pointers for the producer and two pointers for the consumer. In the present technology, circular buffer metadata is provided for these four pointers, which can be accessed and updated atomically by independent actors. The producer head pointer 56 indicates the head of the queued sequence of the producer in the system, while the producer tail pointer 58 indicates the tail of the queued sequence of the producer in the system. Similarly, the consumer head pointer 60 indicates the head of the queued sequence of the consumer in the system, and the consumer tail pointer 62 indicates the tail of the queued sequence of the consumer in the system. A notable point worth noting in this context is that as Figure 2As shown, the producer head pointer 56, the producer tail pointer 58, the consumer head pointer 60, and the consumer tail pointer 62 (in this example, each of which is represented by a scalar value) are provided by metadata stored in the circular buffer metadata storage circuit 34 in the memory 22 (as Figure 1 shown), and the metadata of the circular buffer is accessed by actors (e.g., threads T0 24, T1 26, T2 28, or T3 30) according to atomic operations.

[0068] Now referring to Figure 3 , some difficulties that may arise regarding coordinating the use of a circular buffer in a data processing system among the difficulties mentioned above will now be discussed, where multiple processes utilize the circular buffer, and specifically involve multiple producers and consumers. As previously mentioned, there are typically three-step enqueue and dequeue operations for utilizing a circular buffer, and in a system including multiple producers and multiple consumers, enqueueing and dequeueing require synchronization between the producers and consumers. Specifically, updates must be released in the order in which they are acquired (note that the term "update" encompasses the release of both reads and writes). It is important to release read updates in sequence so that the content is not overwritten before it is read. Therefore, a producer or consumer may have to wait for an earlier producer or consumer to complete this operation.

[0069] Figure 3 A scenario in which this interdependence can manifest itself is schematically shown. In utilizing Figure 3In the system of the ring buffer shown, four pointers are defined, namely, a producer head pointer 56, a consumer head pointer 60, a producer tail pointer 58, and a consumer tail pointer 62. In the case where newly generated data items are added at the tail end of the queuing sequence, when the producer wishes to enqueue a new data item using the ring buffer, it writes to the producer tail pointer 58 and the consumer tail pointer 62. Conversely, when the consumer wishes to dequeue an item, it must update the consumer head pointer 60 and the producer head pointer 56. Thus, in the shown case where slots a, b, c, d, and e are currently in the active queue and the producer wishes to acquire slot f, this acquisition may be achieved by the producer updating the producer tail pointer 58 (the producer updating the producer tail pointer 58 to acquire slot f is indicated by the dashed arrow pointing from the producer tail 58 to slot f), but when the producer attempts to update the consumer tail pointer 62 to indicate data item f, this cannot yet occur on the consumer side, that is, specifically, with respect to the consumer tail pointer 62, it currently still points to data item d, which is indicated by the solid arrow pointing from the consumer tail pointer 62 to slot d. Although as part of the acquisition step of the enqueue operation, the current producer has updated the producer tail pointer 58 to f, the current producer is prevented from updating the consumer tail pointer 62 because the update must be released in the order in which it is acquired (i.e., the consumer tail pointer 62 must first be updated to point to slot e, which is indicated by the dashed line, and then be updated to point to slot f, which is indicated by the dotted line to release the update in the order in which it is acquired), and thus the current producer must wait for the consumer tail pointer 62 to acquire the old value of the producer tail pointer 58, i.e., f.

[0070] The present technique solves this problem by using a method of ring buffer metadata, which includes a first reference indicator and a second reference indicator stored in the ring buffer metadata storage device 34, which allows the producer and the consumer to release updates in order and out of order. Figure 4a A specific implementation of the method is schematically shown, which uses ring buffer metadata, whereby the above situation of waiting for an earlier producer or consumer to complete the release does not occur. In using Figure 4aIn the system of the ring buffer 50 shown, a first reference indicator 66 and a second reference indicator 70 are provided for the head end of the queuing sequence, and a first reference indicator 72 and a second reference indicator 68 are provided for the tail end of the queuing sequence (note that the first reference indicator 66 provided for the head end of the queuing sequence is substantially the same as the first reference indicator 72 provided for the tail end of the queuing sequence, except that the first reference indicator 66 is updated by the consumer and the first reference indicator 72 is updated by the producer). The present technique will be described with reference to the head indicator and the tail indicator, where the head indicator is an example of the first reference indicator provided for the head end of the data item queuing sequence, and the tail indicator is also an example of the first reference indicator provided for the tail end of the data item queuing sequence. Specifically, the present technique provides a head indicator and a tail indicator, where the head indicator is the first reference indicator 66 of the producer at the head end of the queuing sequence, and the tail indicator is the first reference indicator 72 of the consumer at the tail end of the queuing sequence. Each producer can read the head indicator, which is the first reference indicator 66 of the producer, to identify the slot position corresponding to the head of the queuing sequence, and each producer can update the second reference indicator 68 to acquire a slot in the ring buffer and update the first reference indicator 72 to release the slot. Similarly, each consumer can read the tail indicator, which is the first reference indicator 72 of the consumer, to identify the slot position corresponding to the tail of the queuing sequence, and each consumer can update the second reference indicator 70 to acquire a slot in the ring buffer and update the first reference indicator 66 to release the slot. In this way, the head indicator provided for the head end of the queuing sequence provides: an indication of the position of the current slot at the head end of the queuing sequence in the ring buffer; an indication of whether there is one or more updates that have been released out of order by the consumer interacting with the ring buffer at the head end; and an indication of the farthest position of one or more outstanding slots in the ring buffer corresponding to one or more updates that have been released out of order by the consumer interacting with the ring buffer at the head end. Similarly, the tail indicator provided for the tail end of the queuing sequence provides: an indication of the position of the current slot at the tail end of the queuing sequence in the ring buffer; an indication of whether there is one or more updates that have been released out of order by the producer interacting with the ring buffer at the tail end; and an indication of the farthest position of one or more outstanding slots in the ring buffer corresponding to one or more updates that have been released out of order by the producer interacting with the ring buffer at the tail end.To track the current state of valid data items at the head of a queuing sequence in a circular buffer, a head indicator (first reference indicator) 66 including a current slot indicator and a pending slot indicator is provided for the producer head, and a second reference indicator 70 including an expected slot indicator is provided for the consumer head, and a dequeue operation for removing a data item from the head of the queuing sequence for further processing is performed based on an atomic operation that accesses the head indicator 66 and the second reference indicator 70. Similarly, to track the current state of valid data items at the tail of a queuing sequence in a circular buffer of the system, a tail indicator (first reference indicator) 72 including a current slot indicator and a pending slot indicator is provided for the consumer tail, and a second reference indicator 68 including an expected slot indicator is provided for the producer tail, and an enqueue operation for adding a data item to the tail of the queuing sequence is performed based on an atomic operation that accesses the tail indicator 72 and the second reference indicator 68.

[0071] Figure 4b A specific implementation of the method is schematically shown. For the tail of the queuing sequence, circular buffer metadata including the tail indicator 72 and the second reference indicator 68 is used. For a system in which multiple independent actors interact with the circular buffer in parallel, a first producer and a second producer may each attempt to enqueue a data item at the tail of the queuing sequence, where each producer performs an acquisition process to acquire one or more slots of the circular buffer, and the acquisition process includes attempting to update the second reference indicator 68 provided for the producer tail based on an atomic operation (e.g., an atomic acquisition operation that allows each producer to access the circular buffer metadata atomically to acquire one or more slots). For example, the first producer (producer 1) may perform an acquisition process to acquire slot f in the circular buffer by updating the second reference indicator 68 provided for the producer tail to point to slot f (which is represented in Figure 4b by the first producer updating the second reference indicator 68 such that the arrow labeled "A" points to slot f), and the second producer (producer 2) may update the second reference indicator 68 provided for the producer tail to point to slot g (see Figure 4bThe arrow marked "B" pointing to slot g in the figure is used to perform a fetching process to fetch slot g in the circular buffer. The provision of this second reference indicator 68, which is accessed and updated (incremented) atomically by the actor, thus provides a mechanism for the actor that becomes available to fetch a slot in the circular buffer without conflicts occurring between actors for any given slot. It should be noted that "increment" is intended herein to denote a unit modification of a value, and by convention, this can be achieved by addition (e.g., adding one). However, an increase is not necessary, and this "increment" could equally well be chosen to be achieved by subtraction (e.g., subtracting one).

[0072] In this way, each producer updates the second reference indicator 68 by modifying the value of the expected slot indicator according to an atomic operation to fetch one or more slots in the circular buffer, and when the producer successfully fetches one or more slots in the circular buffer, the expected slot value is returned to the producer. Thus, each producer that successfully fetches a slot in the circular buffer will have an expected slot value corresponding to the value of the expected slot indicator at the time the producer fetches the slot. When the first producer successfully fetches slot f, the expected slot value indicating the position of slot f can be returned to the first producer, and when the second producer successfully fetches slot g in the circular buffer, another expected slot value indicating the position of slot g can be returned to the second producer. The first producer and the second producer can simultaneously write to the fetched slot f and the fetched slot g respectively, and subsequently the first producer and the second producer can each perform a release process, which includes attempting to update the tail indicator 72 provided for the consumer tail in order to release the fetched slot with the written data. Thus, each producer will attempt to release the slot fetched by that producer based on a comparison of the producer's expected slot value with the current slot indicator of the tail indicator 72, and when the producer's attempt to update the tail indicator 72 is successful, at least one of the current slot indicator and the outstanding slot indicator of the tail indicator 72 will be updated.

[0073] In some cases, the first producer may finish before the second producer, and the first producer will attempt to update the tail indicator 72 to release slot f before the second producer attempts to update the tail indicator 72 to release slot g. In this case, the first producer will attempt to update the tail indicator 72 according to an atomic operation in which the first producer compares the expected slot value (the value returned to the first producer when the second reference indicator is updated according to the atomic operation) with the current slot indicator of the tail indicator 72. When performing the release process, the first producer accesses the tail indicator 72 atomically and compares the expected slot value with the current slot indicator of the tail indicator 72. When the current slot indicator matches the expected slot value, this indicates that the first producer is attempting to release the slot in order relative to the order of the queuing sequence. Accordingly, when the value of the current slot indicator matches the expected slot value, the release process atomically updates the current slot indicator of the tail indicator 72 provided for the consumer tail by modifying the value of the current slot indicator by a predetermined amount in order to indicate the position of slot f (which is represented by the arrow labeled "C" pointing to slot f). To support enqueueing and dequeueing of multiple slots by the process, range comparison may be used to compare the expected slot value with the current slot indicator. By updating the current slot indicator of the tail indicator 72 provided for the consumer tail in this way, the first producer releases its update. Similarly, when the second producer finishes after the first producer has released slot f by updating the tail indicator 72, the second producer will attempt to update the tail indicator 72 to release slot g (which is represented by the arrow labeled "D" pointing to slot g), and will release the slot in order relative to the order of the queuing sequence. It should be understood that this provides an example of the first producer and the second producer each obtaining a slot and each updating the current slot indicator of the tail indicator 72 to release the update in order.

[0074] In some cases, the second producer may finish before the first producer, and the second producer will attempt to update the tail indicator 72 to free slot g before the first producer attempts to update the tail indicator 72 to free slot f. This is an example of multiple producers interacting with the circular buffer and releasing their updates out of order relative to the queuing sequence. In this case, the second producer will attempt to update the tail indicator 72 according to an atomic operation in which the second producer compares the second producer's expected slot value with the current slot indicator of the tail indicator 72. When performing the release process, the second producer atomically accesses the tail indicator 72 and compares the expected slot value with the current slot indicator of the tail indicator 72. In this case, since the first producer has not yet freed slot f and the second producer is thus attempting to update the tail indicator 72 to free slot g out of order relative to the queuing sequence, the value of the current slot indicator of the tail indicator 72 does not match the second producer's expected slot value. When the current slot does not match the expected slot value, this indicates that the producer is attempting to free slots in order relative to the queuing sequence, and thus the pending slot indicator of the tail indicator 72 is updated by modifying the value of the pending slot indicator to indicate the presence and location of the pending slots in the circular buffer without updating the current slot indicator. Specifically, for the case where the second producer attempts to release its update before the first producer (i.e., release out of order), the second producer atomically accesses the tail indicator 72 and updates the pending slot indicator to indicate that slot g is a pending slot. In this way, a producer can release updates out of order by updating the pending slot indicator to indicate the presence in the circular buffer of slots that have been released by the producer without having to wait for any earlier acquired slots to be released by other producers. Thus, in effect, the pending slot indicator can be atomically updated by a producer that releases updates out of order, and this allows such producers to be free without having to wait for earlier producers.

[0075] This action of attempting to update the tail indicator 72 can be implemented in various ways, but in some embodiments, attempting to update the tail indicator 72 includes an atomic compare-and-swap (CAS) operation that atomically: reads the value of the current slot indicator from the tail indicator 72; compares the value of the current slot indicator with the actor's expected slot value by the actor performing the atomic operation; and depending on whether these values match, this indicates whether the actor is attempting to release the update in order or out of order. In addition to atomically reading the value of the current slot indicator, the value of the pending slot indicator can also be atomically read from the tail indicator 72 to provide an indication as to whether there is one or more pending updates based on the value associated with the pending slot indicator.

[0076] After an unordered release by the outstanding slot indicator producer that updates the tail indicator 72, other producers in the system will release their updates by attempting to update the tail indicator 72 and will continue to further update the outstanding slot indicator when the current slot indicator of the tail indicator 72 does not match the producer's expected slot value, in order to indicate the presence and location of additional outstanding slots. When a producer attempts to atomically update the tail indicator 72 and the current slot indicator matches the producer's expected slot value, which indicates that the producer is attempting to release slots in order relative to the order of the queuing sequence, and the outstanding slot indicator indicates the presence of one or more outstanding slots, this indicates that the circular buffer is in order and there are one or more outstanding slots. In this case, one or more outstanding slots indicated by the outstanding slot indicator are identified, and the tail indicator 72 is updated by modifying the value of the current slot indicator according to the number of consecutive outstanding slots indicated by the outstanding slot indicator as adjacent to the current slot, and the consecutive outstanding slots adjacent to the current slot can be released. In this way, a system using a circular buffer can identify when the system is consistent with outstanding updates, and the tail indicator 72 can be updated such that previous updates to the outstanding slot indicator are released, which preserves the order of the sequence of data items. Accordingly, multiple producers can perform enqueue operations concurrently to add data items to be processed to the queuing sequence in parallel, and each producer can update the current slot indicator or the outstanding slot indicator of the tail indicator 72 according to whether the producer is releasing in an ordered or unordered manner. This technique allows control of the update to the current slot indicator such that the update can be released unordered, but the order in which data items are added to the queuing sequence can be preserved.

[0077] Figure 4c A similar specific implementation of the method is schematically shown. For the head end of the queuing sequence, circular buffer metadata including a head indicator (first reference indicator) 66 and a second reference indicator 70 is used. For a system in which multiple independent actors interact with the circular buffer in parallel, a first consumer and a second consumer can each attempt to dequeue a data item at the head end of the queuing sequence, where each consumer performs an acquisition process to acquire one or more slots of the circular buffer, and the acquisition process includes attempting to update the second reference indicator 70 provided for the consumer head based on an atomic operation (i.e., an atomic acquisition operation that allows each consumer to atomically access the circular buffer metadata to acquire one or more slots). For example, a first consumer (Consumer 1) can perform an acquisition process to acquire slot a in the circular buffer by updating the second reference indicator 68 provided for the producer tail to point to slot a (see the arrow labeled "W" in Figure 4c ), and a second consumer (Consumer 2) can update the second reference indicator 70 provided for the consumer head to point to slot b (seeFigure 4c The fetch process is performed (by the arrow marked "X" in the figure) to fetch slot b in the circular buffer. The provision of this second reference indicator 70, which is read and updated atomically by the consumer, thus provides a mechanism for enabling the consumer that becomes available to fetch a slot in the circular buffer without conflicts occurring among the consumers for any given slot.

[0078] Each consumer can update the second reference indicator 70 to fetch one or more slots in the circular buffer, and the expected slot value will be returned to the consumer when the consumer successfully fetches one or more slots in the circular buffer. The first consumer and the second consumer can simultaneously read data from the fetched slot a and the fetched slot b respectively, and then the first consumer and the second consumer can each perform a release process, which includes attempting to update the header indicator 66 provided for the producer head to release the fetched slot.

[0079] Similar to the technique regarding the tail end of the queuing sequence mentioned above Figure 4b In some cases, the first consumer can complete before the second consumer (i.e., in order) or the first consumer can complete after the second consumer (i.e., out of order), and a given consumer can update the current slot indicator or the pending slot indicator of the header indicator 66 according to whether the consumer is releasing in an ordered manner or an unordered manner, so as to allow the consumer to release its update while maintaining the sorting of the queuing sequence. When releasing the update, the first consumer attempts to update the header indicator 66 according to an atomic operation, in which the first consumer compares the expected slot value with the current slot indicator of the header indicator 66. By comparing the expected slot value with the current slot indicator, the first consumer can identify whether the order of the first consumer relative to the queuing sequence is ordered or unordered. When the current slot indicator matches the expected slot value of the first consumer, the consumer release process atomically updates the current slot indicator of the header indicator 66 provided for the producer head by modifying the value of the current slot indicator to indicate the position of slot a (represented by the arrow marked "Y" pointing to slot a). By updating the current slot indicator of the header indicator 66 provided for the producer head in this way, the first consumer releases its update to the circular buffer metadata. Similarly, when the second consumer completes after the first consumer has released slot a by updating the header indicator 66, the second producer will attempt to update the header indicator 66 to release slot b (which is represented by the arrow marked "Z" pointing to slot b), and thus will release the slot in order relative to the queuing sequence.

[0080] In some cases, the second consumer may complete before the first consumer, in which case the second consumer compares the expected slot value with the current slot indicator of the header indicator 66, and the values compared do not match because the second consumer is attempting to update the header indicator 66 out of order. As such, the second consumer releases the update by updating the pending slot indicator of the header indicator 66 to indicate that slot b is the pending slot. Thus, in effect, the pending slot indicator can be updated atomically by a consumer that releases the update out of order, and this allows such consumers to be free without having to wait for an earlier consumer to complete.

[0081] Figure 5 Schematically shown is a circular buffer metadata structure provided by the present technology to support the method. The circular buffer metadata storage device 34 stores metadata including tail metadata 35 and head metadata 36, which are respectively used to track the tail end and the head end of the queuing sequence, wherein the tail metadata 35 and the head metadata 36 are updated atomically by actors (e.g., threads) executing on the kernels 12, 14. The tail metadata 35 includes a first reference indicator (tail indicator) 72, a second reference indicator 68, and a ring size indicator 73. Similarly, the head metadata 36 includes a first reference indicator (header indicator) 66, a second reference indicator 70, and a ring size indicator 67. Updates made by the producer to the tail metadata 35 allow the system to track enqueue operations, while updates made by the consumer to the head metadata 36 allow the system to track dequeue operations. In some examples, the first reference indicators 66, 72 are 64-bit scalar values, which include: 32 bits assigned to the current slot indicator; and 32 bits assigned to the pending slot indicator, and the second reference indicators 68, 70 may be 32-bit scalar values, and the ring size indicators 73, 67 may also be 32-bit scalar values. It should be noted that other sizes are also considered for the scalar values used to track the circular buffer. For example, in some cases, the first reference indicators 68, 70 may be represented by scalar values including more than 64 bits, and the pending slot indicators of the first reference indicators 68, 70 may be represented by scalar values including more than 32 bits. It should be understood that, as Figure 5 shown, the corresponding instances are stored in a manner that enables atomic access to the corresponding indicators.

[0082] The circular buffer metadata includes a ring size indicator 73, which can be, for example, a 32-bit scalar value that indicates the size of the circular buffer according to the number of corresponding elements. A circular buffer with x elements can be used to implement a data item queuing sequence that occupies at most x - 1 elements at any given time, because there is always at least one empty slot in the circular buffer to distinguish when the circular buffer is full and when it is empty by differentiating the positions of the head and the tail. Alternatively, a circular buffer with x elements can be used to implement a data item queuing sequence that occupies at most x elements at any given time, provided that an additional bit is provided to indicate whether the circular buffer is fully occupied. In some examples, the circular buffer has a plurality of elements given by 2 N (N is an integer), and each element has a storage location in the memory 22. An actor interacts with the circular buffer to enqueue new data items at the tail end and dequeue old data items at the head end, and updates the head pointer and the tail pointer in such a way that the positions of the head and the tail move cyclically around the circular buffer. By accessing the ring size indicator 73 and the head pointer and the tail pointer stored in the circular buffer metadata storage device 34, the number of occupied (non-empty) slots in the circular buffer and thus also the number of unoccupied (empty) slots can be determined. As will be described later with reference to Figure 7 the ring size indicator 73 can be accessed by the actor to ensure that the occupied slots are not overwritten when performing the fetch process as part of the enqueue operation.

[0083] The pending slot indicator includes a limit indicator that indicates the position of the farthest pending slot that is farthest from the current slot in the circular buffer with respect to the order of the queuing sequence. The pending slot indicator also includes a change indicator whose change indicates a change in the number of pending slots between the current slot and the farthest pending slot. When an actor releases an update out of order, the pending slot indicator is atomically updated by the actor to modify the value associated with the pending slot indicator. The modification of the value of the pending slot indicator includes the modification of at least one of the limit indicator and the change indicator. In the absence of pending slots, an actor performing a release process to release an out-of-order update will attempt to atomically access the first reference indicators 66, 72 and, when successful, will update the limit indicator of the pending slot indicator to indicate the position of the pending slot relative to the current slot indicated by the current slot indicator. In other words, when the pending slot indicator indicates the absence of pending slots, the update of the pending slot indicator can modify the value of the limit indicator without updating the change indicator. Alternatively, the change indicator can be updated whenever an actor releases an out-of-order update, such that the change indicator is always updated in response to a release made by an out-of-order actor.

[0084] In the case where there is a single outstanding slot, as indicated by the limit indicator of the outstanding slot indicator (as described in the previous paragraph), a release process is performed to release the actor of the unordered update. The actor will attempt to atomically access the first reference indicator and will update the outstanding slot indicator by modifying the value of the limit indicator or the change indicator depending on the position of the slot that the actor is attempting to release relative to the slot indicated by the limit indicator. If the actor is attempting to release a slot that is located further from the current slot than the position of the outstanding slot indicated by the limit indicator, the actor will update the outstanding slot indicator by modifying the value of the limit indicator to indicate the position of the slot that the actor is attempting to release. If the actor is attempting to release a slot that is not located further from the current slot than the position of the outstanding slot indicated by the limit indicator (i.e., the actor is attempting to release a slot that is closer to the current slot than the outstanding slot indicated by the limit indicator), the actor will update the outstanding slot indicator by modifying the value of the change indicator without updating the limit indicator. Thus, the actor will update the change indicator to indicate that there is a new outstanding slot between the current slot and the furthest outstanding slot from the current slot indicated by the limit indicator. It should be understood that the corresponding actor attempts to atomically access the first reference indicator to update the first reference indicator and updates the outstanding slot indicator by modifying a portion of the 64-bit value associated with the first reference indicator.

[0085] Figure 6 An exemplary sequence of steps taken in one embodiment when performing an atomic fetch process is shown. The process begins at step 610 where a process in the system wishes to fetch one or more slots in the circular buffer. At step 620, the process calls an update process (to be described in more detail below with respect to Figure 7 to attempt to atomically access the circular buffer metadata and update the circular buffer metadata. Specifically, the process attempts to atomically access the circular buffer metadata and update the second reference indicator. Then at step 630, it is determined whether an update has been made (by another process) while this local process continues. When it is determined that an update has been made (by another process), the flow returns to step 620 and the process calls the update process again to attempt to atomically access the circular buffer metadata and update the circular buffer metadata. When it is determined at step 630 that the circular buffer metadata has not been updated while this local process continues, then the flow proceeds to step 640 where the fetch process is completed.

[0086] In an embodiment of the present technology, the enqueue (producer) operation and the dequeue (consumer) operation may obtain a slot in the circular buffer by implementing an atomic fetch operation, where both the consumer and the producer may use a common atomic fetch operation to obtain a slot in the circular buffer at the head or the tail of the queuing sequence. Accordingly, the atomic operation for obtaining a slot in the circular buffer may be used by both the producer and the consumer, where the difference between the enqueue fetch operation and the dequeue fetch operation is that the enqueue fetch operation needs to know the ring size to obtain a slot in the circular buffer, while the dequeue fetch operation does not need to know the ring size to obtain a slot in the circular buffer. This difference between the enqueue fetch operation and the dequeue fetch operation occurs because the dequeue fetch operation can only dequeue the slots that have been written in the circular buffer (i.e., dequeue should not be performed to obtain an empty (unoccupied) slot in the circular buffer and should only be performed to obtain as many slots as the occupied slots in the circular buffer), while the enqueue fetch operation is performed to obtain an empty slot in the circular buffer. In other words, calculating the number of slots eligible for obtaining for the enqueue operation in the circular buffer requires a calculation that determines the size of the circular buffer (the circular buffer size is obtained by accessing the circular buffer metadata, specifically by accessing the ring size indicators 67, 73 to determine the size of the circular buffer), and calculates the difference between the positions of the head and the tail to find the position of obtaining a slot in the circular buffer without overwriting the content before it should be read. As part of the enqueue fetch operation, the positions of the head and the tail are obtained, and the number of slots eligible for obtaining in the circular buffer (i.e., the number of empty slots) may be determined based on the following calculation: number of eligible slots = ring_size - (tail position - head position). Accordingly, the number of eligible slots may be determined for the enqueue fetch operation such that the number of slots that can be obtained by the actor is limited to the number of currently unoccupied slots. As part of the dequeue fetch operation, the positions of the head and the tail are obtained to determine the positions and the number of occupied slots in the circular buffer. For the dequeue fetch operation, the number of slots eligible for obtaining in the circular buffer may be determined based on the following calculation: number of eligible slots = tail position - head position.

[0087] The consumer performs a dequeue fetch operation to attempt to atomically access and update the second reference indicator 70 (consumer) provided for the head of the queuing sequence to obtain one or more slots at the head of the queuing sequence. Similarly, the producer performs an enqueue fetch operation to attempt to atomically access and update the second reference indicator 68 provided for the tail of the queuing sequence to obtain one or more slots at the tail of the queuing sequence. Figure 7Shows a sequence of steps taken in one embodiment when performing an atomic fetch process, specifically (as shown in the first step 700) when the process wishes to attempt to update a second reference indicator provided to the head (consumer) or tail (producer). In this case, the slot position indicator at the tail end of the queuing sequence (which is updated by the producer to indicate the position of the tail end) is an example of the second reference indicator, and the slot position indicator at the head end of the queuing sequence (which is updated by the consumer to indicate the position of the head end) is another example of the second reference indicator. At step 701, the process determines the number of slots to be fetched, and the process attempts to fetch the number of slots in the circular buffer by atomically accessing and updating the circular buffer metadata. At step 702, it is determined whether the process is attempting to fetch slots for enqueueing (i.e., at the tail end of the queuing sequence) or for dequeueing (i.e., at the head end of the queuing sequence). When it is determined at step 702 that the process is attempting to fetch slots for enqueueing, the flow proceeds to step 703, where the number of slots eligible for fetching for enqueueing is calculated based on the ring size (or the capacity of the circular buffer), the position of the head, and the position of the tail. The number of occupied slots in the circular buffer is given by tail - head, and thus at step 703, the calculated ring size - (tail - head) is used to calculate the number of slots eligible for fetching for enqueueing. When it is determined at step 702 that the process is attempting to fetch slots for dequeueing, the flow proceeds to step 704, where the number of slots eligible for fetching for dequeueing is calculated using the calculated tail - head based on the position of the head and the position of the tail. At step 705, the calculated number of eligible slots is compared with the number of slots the process is attempting to fetch. When it is determined at step 705 that the number of eligible slots is greater than the number of slots the process is attempting to fetch, the flow proceeds to step 706, where the second reference indicator is updated to reflect that one or more slots have been fetched by the process. When it is determined at step 705 that the number of eligible slots is less than the number of slots the process is attempting to fetch, the flow proceeds to step 707, where it is determined whether the number of eligible slots is equal to zero, in which case the process cannot fetch any slots in the circular buffer. When it is determined at step 707 that the number of eligible slots is equal to zero, the flow returns to step 702 to retry fetching the slots, or optionally a value can be returned to the process, indicating that no slots have been fetched, and the process can decide whether to retry the fetch operation that started at step 700. When it is determined at step 707 that the number of slots is not equal to zero, the flow proceeds to step 706 to update the second reference indicator. Thus, when the number of eligible slots in the circular buffer is less than the number of slots the process is attempting to fetch, the process can fetch multiple slots in the circular buffer, although the process cannot fetch all the slots it is attempting to fetch.Alternatively, when the process cannot obtain the total number of slots requested to be obtained, the process can return to step 702. Once the process updates the second reference indicator according to the number of slots to be obtained in the circular buffer at step 706, the process proceeds to step 708, where it is determined whether the second reference indicator has changed while the process is being executed. At step 708, when it is determined that the second reference indicator has changed during the processing, the process returns to step 702, such that the update of the second reference indicator is not completed and thus fails, and the process retries updating the second reference indicator (i.e., when the second reference indicator has been changed by another process during the time the processing is being executed, the attempt to obtain slots fails). Thus, the process will continue to attempt to update the second reference indicator until it is determined at step 708 that the second reference indicator has not changed during the processing. When it is determined at step 708 that the second reference indicator has not changed during the processing, the process proceeds to step 709, such that the second reference indicator is updated atomically, and the expected slot value indicating the initial value of the second reference indicator and the value indicating the number of slots obtained by the process are returned to the process. Thus, at step 709, two values are returned to the process, the first value corresponding to the value of the second reference indicator when the process obtains one or more slots and thus indicating the position of the first slot in the circular buffer that can be used by the process for writing (enqueueing) or reading (dequeueing), and the second value indicating the number of slots obtained due to the atomic acquisition operation. This means that the values returned to the process can be used by the process to determine where to perform the enqueue or dequeue operation in the circular buffer, and the value indicating the number of slots obtained by the process can be used to determine whether the process has obtained all or some of the slots it has attempted to obtain.

[0088] Figure 8 An exemplary sequence of steps taken in one embodiment when performing a non-blocking release process is shown. The process begins at step 810, where a process in the system wishes to release one or more slots. At step 820, the process calls an update process (to be described in more detail below with respect to Figure 9 to attempt to atomically access the circular buffer metadata and update the circular buffer metadata. Specifically, when the process obtains one or more slots, the process attempts to atomically access the circular buffer metadata and according to the expected slot value returned to the process (as previously with respect to Figure 6 and Figure 7Update the first reference indicator (discussed). This attempt by the process to update the first reference indicator is a "critical section", which in its meaning means that it must be performed in the original way, because different processes can simultaneously attempt to access and update the first reference indicator atomically. Therefore, the operations performed in this "critical section" can be implemented using a compare-and-swap (CAS) operation, so that these processes can access and update the circular buffer metadata atomically and when these processes all attempt to update the first reference indicator simultaneously, another process can be temporarily blocked from releasing its update by another process. In other words, these processes can access and update the circular buffer metadata atomically, and if another process attempts to update the first reference indicator simultaneously, a process may have to retry releasing its update. This may mean that a process can be blocked by another process. However, each process is limited to a short interaction in this "critical section", and the blocking of a process by another process during this section does not constitute a significant time constraint. At step 830, it is determined whether an update has been made (by another process) while this local processing continues. When it is determined that an update has been made (by another process), the process flow returns to step 820, and the process calls the update process again to attempt to access the circular buffer metadata atomically and update the circular buffer metadata. When it is determined at step 830 that the circular buffer metadata has not been updated while this local processing continues, then the process flow proceeds to step 840, where the release process is completed.

[0089] Figure 9 Illustrates a sequence of steps taken in one implementation when performing an atomic release process, specifically (as shown in the first step 900) when a process wishes to attempt to update the first reference indicator. In this case, the first reference indicator provides: an indication of the position of the current slot of the circular buffer; an indication of whether there is one or more updates that have been released out of order by an actor interacting with the circular buffer; and an indication of the position of one or more pending slots in the circular buffer corresponding to one or more updates that have been released out of order by an actor interacting with the circular buffer. Therefore, a head indicator or a tail indicator that indicates the position of the current slot and also indicates the existence and position of one or more pending slots in the queuing sequence is an example of the first reference indicator, which can be updated by an actor that releases updates in order or out of order with respect to the order of the data item queuing sequence. The head indicator or the tail indicator, which is an example of the first reference indicator, includes three corresponding indicators: a current slot indicator, a change indicator, and a limit indicator. Accordingly, a process that wishes to attempt to update the head indicator or the tail indicator will attempt to update at least one of the current slot indicator, the change indicator, and the limit indicator according to the Figure 9 processing shown.

[0090] When the process has completed the write or read phase of an enqueue or dequeue operation, the process begins the release process and thus expects to attempt to update the first reference indicator at step 900. At step 901, the expected slot value returned to the process when the process acquires one or more slots is maintained by the process for comparison with the circular buffer metadata. At step 902, it is determined whether the expected slot value maintained by the process matches the value of the current slot indicator of the first reference indicator. As discussed, this attempt to update the circular buffer metadata can be implemented based on an atomic compare-and-swap (CAS) operation. When the expected slot value does not match the value of the current slot indicator, which indicates that the process is attempting to release an update out of order relative to the data item sorting sequence (i.e., the process is releasing an update "ahead" or "behind" the order of the data item queuing sequence), the flow proceeds to step 903, where it is determined whether the process is attempting to release an update in a way that is "ahead" of the data item sorting sequence. At step 903, the expected slot value is compared with the value of the current slot indicator, and when the expected slot value indicates a slot that is not in front of the slot position indicated by the current slot indicator (i.e., not ahead and not matching the current value and thus must be "behind" it), then the flow proceeds to step 911 without updating the circular buffer metadata. At step 911, a value is returned to the process indicating that the process has completed the release of a non-blocking process. Thus, when the process is attempting to release an update "behind" the order of the queuing sequence, a value can be returned to the process, and in this case, the process can complete the non-blocking release process without updating the first reference indicator.

[0091] When it is determined at step 903 that the expected slot value indicates a slot that is in front of the slot position indicated by the current value, then the process proceeds to step 904, where the pending slot indicator of the first reference indicator is updated by the process to indicate the presence and location of one or more pending slots corresponding to the update that the process is attempting to release. It should be understood that the process will, at step 903, update at least one of the limit indicator and the transform indicator of the pending slot indicator in the manner previously described depending on the position indicated by the expected slot value relative to the position indicated by the value of the current slot indicator and also depending on whether one or more pending slots are currently already indicated by the pending slot indicator. Once the process has updated the pending slot indicator at step 904, the process proceeds to step 910, where it is determined whether the first reference indicator has changed while the process is being executed (i.e., whether the current slot indicator or the pending slot indicator of the first reference indicator has changed during the time the process is being executed). At step 910, when it is determined that the first reference indicator has changed during the process, the process returns to step 901, causing the update of the first reference indicator to fail (the update of the pending slot indicator at step 904 was not completed and thus failed), and the process reattempts to update the first reference indicator. Thus, the process will continue to attempt to update the first reference indicator until a return value is obtained at step 911. When it is determined at step 910 that the first reference indicator has not changed during the process, the process proceeds to step 911, where the first reference indicator is updated atomically and a value is returned to the process at step 911, indicating that the process has completed the release of the non-blocking process.

[0092] Referring again to step 902, when it is determined that the expected slot value does indeed match the value of the current slot indicator, which indicates that the process is attempting to release updates in order relative to the data item sorting sequence, the process then proceeds to step 905, where the process determines whether the pending slot indicator indicates whether there is one or more pending slots in the circular buffer. When it is determined at step 905 that there are no pending slots, the process proceeds to step 907, where the process updates the current slot indicator to modify the value of the current slot indicator according to the expected value. When the current slot indicator has been updated at step 907, the process proceeds to step 910, where it is determined whether the first reference indicator has changed while the process is being executed, and when it is determined that the first reference indicator has changed during the time the process is being executed, the process returns to step 901, causing the update of the first reference indicator to fail (i.e., the update of the current slot indicator at step 907 is not completed and thus fails). When it is determined at step 905 that the pending slot indicator indicates the existence of one or more pending slots, the process proceeds to step 906, where it is determined whether any one of the one or more pending slots is adjacent to the slot indicated by the current value. This can be achieved by using the pending slot indicator to scan the pending slots located between the current slot and the farthest pending slot indicated by the limit indicator. The sequential process can perform a scan of the pending slots located between the current slot and the farthest slot. In some examples, when the value of the change indicator changes during the scan, this indicates that the number of pending slots between the current slot and the farthest pending slot has changed, and thus the process can rescan the circular buffer between the current slot and the farthest pending slot to identify whether there are any pending slots that can be released in order. When there are one or more pending slots, none of which is adjacent to the slot indicated by the current value, the process proceeds to step 907, where the current slot indicator is updated. However, when it is determined at step 906 that one or more of the pending slots are adjacent to the slot indicated by the current value, the process proceeds to step 908, where the process updates the value of the current slot indicator. It should be understood that the value of the current slot indicator is updated at step 908 according to the number of consecutive pending slots determined to be adjacent to the current slot, as described above. When the current slot indicator is updated at step 908, the process proceeds to step 909, where the pending slot indicator is updated according to the update of the current slot indicator at step 908. Thus, at step 909, after the current slot indicator has been updated at step 908, the pending slot indicator is updated to indicate the existence and location of one or more pending slots in the circular buffer. In this way, the pending slot indicator can be updated at step 909 such that one or more pending slots determined not to be adjacent to the slot indicated by the current value at step 908 can be indicated by the pending slot indicator.In the case where all outstanding slots are determined at step 906 to be adjacent to the slot indicated by the current value, the update to the outstanding slot indicator 909 can be such that the outstanding slot indicator is updated to indicate that there are no outstanding slots. When the outstanding slot indicator has been updated at step 909, the process proceeds to step 910, where an atomic compare-and-swap (CAS) operation, for example, is used to determine whether the first reference indicator has changed while the process is being executed. When it is determined at step 910 that the first reference indicator has changed during the processing, the process returns to step 901, such that the update to the first reference indicator fails and the process retries updating the first reference indicator. When it is determined at step 910 that the first reference indicator has not changed during the processing, the process proceeds to step 911, and the value is returned to the process, indicating that the process has completed a non-blocking release process.

[0093] Figure 10 A data processing apparatus 100 is schematically shown that can embody various examples of the present technology. The apparatus includes data processing circuitry 120 that performs data processing operations on data items in response to a sequence of instructions it executes. For example, the data processing circuitry 120 may include Figure 1 the cores 12 and 14 shown, on which threads T0, T1, T2, and T3 execute. Instructions are retrieved from a memory 140 accessible to the data processing circuitry 120, and an extraction circuit 160 is provided for this purpose in a manner familiar to those of ordinary skill in the art. Note that the memory 140 accessible to the data processing apparatus may include Figure 1 and Figure 5 the ring buffer storage device 32 and the ring buffer metadata storage device 34 shown. In addition, the instructions retrieved by the extraction circuit 160 are passed to an instruction decoder circuit 180 that generates control signals that are arranged to control various aspects of the configuration and operation of the processing circuitry 120 and the register bank 200 and the load / store unit 220. Generally speaking, the data processing circuitry 120 may be arranged in a pipelined manner, but the details are not relevant to the present technology. Those of ordinary skill in the art will be familiar with Figure 10 the general configuration represented, and for the sake of brevity, further detailed description thereof is omitted herein. As can be seen in Figure 10 each of the registers 200 includes storage for a plurality of data elements, such that the processing circuitry 120 can apply data processing operations to a specified data element within a specified register, or can apply data processing operations to a specified group of data elements (“vectors”) within a specified register.

[0094] The data values required by the data processing circuit 120 when executing instructions, as well as the data values generated as a result of these data processing instructions, are written to and read from the memory 140 by means of the load / store unit 220. It should also be noted that Figure 1 the memory 140 in Figure 1 can generally be regarded as an example of a computer-readable storage medium on which the instructions of the present technology can be stored, typically as part of a predefined sequence of instructions ("program") subsequently executed by the processing circuit. However, the processing circuit can access such programs from various different sources (such as in RAM, in ROM) via a network interface, etc. The present disclosure provides instructions that the processing circuit 120 can execute to atomically access and update the circular buffer metadata 34, as Figure 5 shown. In this way, actors in the system can execute instructions to access the metadata 34, which includes tail metadata 35 and head metadata 36 for tracking the tail end and the head end of the queuing sequence. Instructions are provided that can be executed by the actors to atomically acquire slots in the circular buffer and to atomically release slots in the circular buffer.

[0095] Therefore, the present technology provides circular buffer acquisition instructions, and these instructions can form part of a sequence of instructions retrieved from the memory 140 and executed by the processing circuit 120, as described above. Therefore, it should be understood that in such examples, the above-mentioned actors are embodied as processes executed in the processing circuit 120, and they can utilize the defined circular buffer acquisition instructions to perform an atomic acquisition operation to acquire one or more slots in the circular buffer by atomically accessing and updating the circular buffer metadata 34.

[0096] As in the following example, the circular buffer acquisition instructions can include three variants of the circular buffer acquisition instructions: acquisition order (A); release order (L); and acquisition and release order (AL). Therefore, these variants can be represented as:

[0097] RBACQ[E,D]{A,L,AL} <xs> , <wt>, [<Xn|SP>],

[0098] where E indicates that the instruction is for enqueueing, and D indicates that the instruction is for dequeueing. In these examples, the registers specified in the instruction are:

[0099] <wt>- 32 - bit general - purpose registers, where the number of requested items is encoded in the destination register field.

[0100] <xs>- The 64-bit general-purpose register will load the starting index of the origin and the actual number of items encoded in the source register field.

[0101] <Xn|SP> - The 64-bit base register or SP is encoded in the additional register field.

[0102] Therefore, the 32-bit general-purpose register <wt>Specify the number of slots requested by the actor. 64-bit general-purpose register <xs>Loaded with the starting index for the circular buffer and the number of slots taken by the actor. Note that this 32-bit general-purpose register <wt>, the 64-bit general-purpose register <xs>And the 64-bit base address register <Xn|SP> is a specific parameter of the circular buffer fetch instruction.

[0103] Similarly, the present disclosure provides circular buffer release instructions, and these instructions may also form part of an instruction sequence retrieved from the memory 140 and executed by the processing circuit 120, as described above. Thus, it should be understood that in such examples, the above actors are embodied as processes executed in the processing circuit 120, and they may utilize the defined circular buffer release instructions to perform an atomic fetch operation to release one or more slots in the circular buffer by atomically accessing and updating the circular buffer metadata 34.

[0104] For example, the circular buffer release instructions may include three variants of the circular buffer fetch instruction: fetch order (A); release order (L); and fetch and release order (AL). Thus, these variants may be represented as:

[0105] RBREL{A,L,AL} <xs> , <xt>, [<Xn|SP>].

[0106] In these examples, the registers specified in the instruction are:

[0107] <xt>- 64 - bit general - purpose registers, where the starting index and the number of items to be freed are encoded in the source register field.

[0108] <xs>- 64-bit general-purpose register that will be loaded with the current: pending old value.

[0109] <Xn|SP> - 64-bit base register or SP, encoded in the additional register field.

[0110] Therefore, the 64-bit general-purpose register <xt>Specify the starting index of the circular buffer and the number of slots to be released by the actor. 64-bit general-purpose register <xs>Load the expected value with the expected slot indicator. 64-bit general-purpose register <xt> 、 <xs>And <Xn|SP> are specific parameters of the ring buffer release instruction set.

[0111] Accordingly, it should be understood that in a system that supports the above ring buffer fetch instruction and ring buffer release instruction, a decoding circuit (such as Figure 10 item 180 in the example of Figure 10 is configured to identify these instructions and assert appropriate control signals (e.g., for

[0112] Figure 11 processing circuit 100, register 200, and load / store unit 220 in the example of

[0113] to cause the above fetching and releasing processes to be performed. Shows a specific implementation of the simulator that can be used. Although the previously described embodiments implement the present invention in terms of apparatus and methods for operating specific processing hardware that supports the technology involved, an instruction execution environment according to the embodiments described herein can also be provided, which is implemented by using a computer program. Such computer programs are commonly referred to as simulators, in part because such computer programs provide a software-based implementation of a hardware architecture. Types of simulator computer programs include emulators, virtual machines, models, and binary translators, including dynamic binary translators. Generally, a simulator implementation can run on a host processor 730 that supports the simulator program 710, which optionally runs a host operating system 720. In some arrangements, there can be multiple simulation layers between the hardware and the provided instruction execution environment and / or between multiple different instruction execution environments provided on the same host processor. Historically, powerful processors have been required to provide simulator implementations that execute at a reasonable speed, but this approach can be reasonable in certain cases, such as when it is desirable to run code native to another processor for compatibility or reuse reasons. For example, a simulator implementation can provide additional functionality to the instruction execution environment that is not supported by the host processor hardware, or provide an instruction execution environment that is typically associated with a different hardware architecture. An overview of simulation is given in: "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pages 53 - 63.

[0113] Where embodiments have been described previously with reference to specific hardware constructs or features, in simulated embodiments, equivalent functionality may be provided by appropriate software constructs or features. For example, a particular circuit may be implemented as computer program logic in a simulated embodiment. Similarly, memory hardware such as registers or cache memory may be implemented as software data structures in a simulated embodiment. Where one or more of the hardware elements referred to in the previously described embodiments are present in an arrangement on host hardware (e.g., host processor 730), some simulated embodiments may utilize the host hardware where appropriate.

[0114] The simulator program 710 may be stored on a computer-readable storage medium (which may be a non-transitory medium) and provide a program interface (instruction execution environment) to the target code 700 that is the same as the application program interface of the hardware architecture that the simulator program 710 is modeling. Thus, the program instructions of the target code 700 (including the above-described circular buffer fetch instruction and circular buffer release instruction) may be executed from within the instruction execution environment using the simulator program 710, such that a host computer 730 that does not actually have the hardware features of the above-described apparatus may mimic those features.

[0115] In short, apparatuses, methods, programs, and circular buffer acquisition and release instructions are provided. A circular buffer storage circuit is disclosed, which stores a circular buffer including a plurality of slots to maintain a queuing sequence of data items. A data processing circuit performs a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing. Each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and then perform a release process to release the at least one slot. A circular buffer metadata storage circuit stores metadata of the circular buffer, which includes a first reference indicator and a second reference indicator. The first reference indicator includes a current slot indicator indicating the position of a current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer. The second reference indicator includes an expected slot indicator indicating the expected position of the current slot, where one or more pending slots have been acquired after the current slot. When the process performs the acquisition process to acquire at least one slot in the circular buffer, the process has an expected slot value indicating the value of the expected slot indicator. The release process includes an attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the process is compared with the current slot indicator. When the current slot indicator matches the expected slot value, at least the current slot indicator is updated by modifying the value of the current slot indicator by a predetermined value. When the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the circular buffer without updating the current slot indicator.

[0116] In this application, the phrase "configured to..." is used to mean that an element of an apparatus has a configuration capable of performing the defined operation. In this context, "configuration" means an arrangement or manner of interconnection of hardware or software. For example, the apparatus may have dedicated hardware providing the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not mean that the apparatus element needs to be changed in any way to provide the defined operation.

[0117] Although the exemplary embodiments have been described in detail herein with reference to the accompanying drawings, it should be understood that the present invention is not limited to those exact embodiments, and various changes, additions, and modifications can be made by those skilled in the art without departing from the scope of the present invention as defined by the appended claims. For example, the features of the dependent claims can be combined with the features of the independent claims in various ways without departing from the scope of the present invention.< / xs> < / xt> < / xs> < / xt> < / xs> < / xt> < / xt> < / xs> < / xs> < / wt> < / xs> < / wt> < / xs> < / wt> < / wt> < / xs>

Claims

1. A data processing apparatus, the apparatus comprising: A circular buffer storage circuit for storing a circular buffer including a plurality of slots to maintain a queuing sequence of data items; A data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and subsequently perform a release process to release the at least one slot; And A circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, the one or more pending slots having been acquired after the current slot, wherein when a given process among the plurality of processes performs the acquisition process to acquire the at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, wherein The release process includes an attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the given process is compared with the current slot indicator, and When the current slot indicator matches the expected slot value, at least the current slot indicator is updated by modifying the value of the current slot indicator by a predetermined value, and When the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the circular buffer without updating the current slot indicator.

2. The apparatus according to claim 1, wherein when the current slot indicator does not match the expected slot value, and the expected slot value indicates that the order of the current slot relative to the queuing sequence is not at an expected position after the current slot indicated by the current slot indicator, the first reference indicator is not updated.

3. The apparatus according to claim 1, wherein when the current slot indicator does not match the expected slot value, the pending slot indicator is updated by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots in the circular buffer relative to the current slot indicated by the current slot indicator.

4. The apparatus according to claim 1, wherein the outstanding slot indicator includes a limit indicator that indicates the position of the farthest outstanding slot that is the farthest from the current slot in the circular buffer with respect to the order of the queuing sequence.

5. The apparatus according to claim 4, wherein the outstanding slot indicator includes a change indicator, and a change in the change indicator indicates a change in the number of outstanding slots between the current slot and the farthest outstanding slot.

6. The apparatus according to claim 5, wherein when the current slot indicator does not match the expected slot value, the outstanding slot indicator is updated by modifying at least one of the limit indicator and the change indicator.

7. The apparatus according to claim 6, wherein when the expected slot value indicates a slot that is farther from the current slot in the circular buffer than the farthest outstanding slot indicated by the limit indicator with respect to the order of the queuing sequence, the limit indicator is updated.

8. The apparatus according to claim 7, wherein the limit indicator is updated based on the expected slot value to indicate a different position of the farthest outstanding slot.

9. The apparatus according to claim 5, wherein when the expected slot value indicates a slot between the current slot and the farthest outstanding slot, the change indicator is updated without updating the limit indicator.

10. The apparatus according to any one of claims 1-9, wherein when the current slot indicator matches the expected slot value and the outstanding slot indicator indicates the presence of one or more outstanding slots in the circular buffer, the current slot indicator is updated by modifying the value of the current slot indicator according to the number of one or more consecutive outstanding slots adjacent to the current slot.

11. The apparatus according to claim 10, wherein the value of the current slot indicator is modified to indicate the farthest outstanding slot among the one or more consecutive outstanding slots, and the farthest outstanding slot is the outstanding slot that is the farthest from the current slot in the circular buffer among the one or more consecutive outstanding slots.

12. The apparatus according to claim 1, wherein the current slot indicator indicates the position of the current slot at the head or tail end of the queuing sequence of the data item, and the expected slot indicator indicates the expected position of the current slot at the same end of the queuing sequence of the data item.

13. The apparatus according to claim 1, wherein the first reference indicator is an indicator that for the process of removing a data item from the queuing sequence, is the tail indicator of the tail end of the queuing sequence of the data item, and the second reference indicator is an indicator that for the process of adding a data item to the queuing sequence, is the tail indicator of the tail end of the queuing sequence of the data item.

14. The apparatus according to claim 13, wherein the process of adding a data item to the queuing sequence is arranged to perform the acquisition process to acquire at least the next unoccupied slot in the circular buffer, the acquisition process including an attempt to update the second reference indicator according to an atomic operation.

15. The apparatus according to claim 1, wherein the first reference indicator is an indicator that, for the process of adding a data item to the queuing sequence, is the head indicator at the head end of the queuing sequence of the data item, and the second reference indicator is an indicator that, for the process of removing a data item from the queuing sequence, is the head indicator at the head end of the queuing sequence of the data item.

16. The apparatus according to claim 15, wherein the process of removing a data item from the queuing sequence is arranged to perform the acquisition process to acquire at least the next occupied slot in the circular buffer, the acquisition process including an attempt to update the second reference indicator according to an atomic operation.

17. The apparatus according to any one of claims 1-9 and 12-16, wherein when the given process performs the acquisition process to acquire the at least one slot in the circular buffer, the second reference indicator is updated by modifying the value of the expected slot indicator according to the number of slots acquired by one of the plurality of processes.

18. The apparatus according to claim 13, wherein the data processing circuit is arranged to perform the process of adding a data item to the queuing sequence in parallel, and each process simultaneously attempts to update the first reference indicator according to the atomic operation.

19. The apparatus according to claim 15, wherein the data processing circuit is arranged to perform the process of removing a data item from the queuing sequence in parallel, and each process simultaneously attempts to update the first reference indicator according to the atomic operation.

20. A method of operating a data processing apparatus, the method comprising the steps of: allocating storage means for a circular buffer including a plurality of slots to hold a queuing sequence of data items; performing a plurality of processes to add one or more data items to be processed to the queuing sequence and to remove one or more data items from the queuing sequence for processing, wherein an acquisition process is performed to acquire at least one slot in the circular buffer, and subsequently a release process is performed to release the at least one slot; Allocate storage for the metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, the one or more pending slots having been acquired after the current slot, wherein when a given one of the plurality of processes performs the acquisition process to acquire at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, wherein the release process includes an attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the given process is compared with the current slot indicator, and when the current slot indicator matches the expected slot value, update at least the current slot indicator by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, update the pending slot indicator by modifying the value of the pending slot indicator to indicate the presence and position of one or more pending slots of the circular buffer without updating the current slot indicator.

21. A data processing apparatus, the apparatus comprising: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to hold a queued sequence of data items; an instruction decoder circuit for decoding instructions; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queued sequence and to remove one or more data items from the queued sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and subsequently perform a release process to release the at least one slot; and a circular buffer metadata storage circuit for storing the metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the presence and position of one or more pending slots among the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, the one or more pending slots having been acquired after the current slot, wherein when a given one of the plurality of processes performs the acquisition process to acquire at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, wherein The instruction decoder circuit responds to a circular buffer release instruction to be executed by the data processing circuit to control the data processing circuit to execute the release process, and the release process includes the following steps: Attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the given process is compared with the current slot indicator, and When the current slot indicator matches the expected slot value, update at least the current slot indicator by modifying the value of the current slot indicator by a predetermined value, and When the current slot indicator does not match the expected slot value, update the pending slot indicator by modifying the value of the pending slot indicator to indicate the existence and location of one or more pending slots of the circular buffer without updating the current slot indicator.

22. A computer program product for controlling a host data processing device to provide an instruction execution environment, and comprising: Circular buffer storage logic for storing a circular buffer including a plurality of slots to hold a queuing sequence of data items; Instruction decoder logic for decoding instructions; Data processing logic for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer and subsequently perform a release process to release the at least one slot; and Circular buffer metadata storage logic for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of the current slot and a pending slot indicator indicating the existence and location of one or more pending slots in the plurality of slots of the circular buffer, and the second reference indicator including an expected slot indicator indicating the expected position of the current slot, the one or more pending slots having been acquired after the current slot, wherein when a given process among the plurality of processes performs the acquisition process to acquire the at least one slot in the circular buffer, the expected slot value is the value of the expected slot indicator, wherein The instruction decoder logic responds to a circular buffer release instruction to be executed by the data processing logic to control the data processing logic to execute the release process, and the release process includes the following steps: Attempt to update the first reference indicator of the circular buffer, including an atomic operation in which the expected slot value of the given process is compared with the current slot indicator, and When the current slot indicator matches the expected slot value, update at least the current slot indicator by modifying the value of the current slot indicator by a predetermined value, and when the current slot indicator does not match the expected slot value, update the pending slot indicator by modifying the value of the pending slot indicator to indicate the presence and the location of one or more pending slots of the circular buffer without updating the current slot indicator.

23. A data processing apparatus, the apparatus comprising: a circular buffer storage circuit for storing a circular buffer including a plurality of slots to hold a queuing sequence of data items; a data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer; and a circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the location of a current slot at one end of the queuing sequence of the data items, and the second reference indicator including an expected slot indicator indicating the expected location of a current slot at the other end of the queuing sequence of the data items, wherein the one end of the queuing sequence of the data items is the head end or the tail end of the queuing sequence of the data items, wherein the acquisition process includes an attempt to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, update the expected slot indicator by modifying the value of the expected slot indicator.

24. The apparatus according to claim 23, wherein the first reference indicator is an indicator: for a process of removing a data item from the queuing sequence, a tail indicator at the tail end of the queuing sequence of the data items, and the second reference indicator is an indicator: for a process of removing a data item from the queuing sequence, a head indicator at the head end of the queuing sequence of the data items.

25. The apparatus according to claim 24, wherein for the process of removing a data item from the queuing sequence, the number of slots eligible for acquisition corresponds to the number of occupied slots in the circular buffer, and wherein the number of occupied slots in the circular buffer is determined based on the location of the current slot at the head end and the location of the current slot at the tail end.

26. The apparatus according to claim 23, wherein the first reference indicator is the following indicator: for the process of adding a data item to the queuing sequence, the head indicator at the head end of the queuing sequence of the data item, and the second reference indicator is the following indicator: for the process of adding a data item to the queuing sequence, the tail indicator at the tail end of the queuing sequence of the data item.

27. The apparatus according to claim 26, wherein for the process of adding a data item to the queuing sequence, the number of slots eligible for acquisition corresponds to the number of unoccupied slots in the circular buffer, and wherein the number of unoccupied slots in the circular buffer is determined based on the total number of slots in the circular buffer, the position of the current slot at the head end, and the position of the current slot at the tail end.

28. A method of operating a data processing apparatus, the method comprising the steps of: Allocating storage for a circular buffer including a plurality of slots to hold a queuing sequence of data items; Performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein an acquisition process is performed to acquire at least one slot in the circular buffer; Allocating storage for metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot at one end of the queuing sequence of the data item, and the second reference indicator including an expected slot indicator indicating the expected position of a current slot at the other end of the queuing sequence of the data item, wherein the one end of the queuing sequence of the data item is the head end or the tail end of the queuing sequence of the data item, wherein The acquisition process includes attempting to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be acquired by the process is compared with the current slot indicator and the expected slot indicator, and When the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, updating the expected slot indicator by modifying the value of the expected slot indicator.

29. A data processing apparatus, the apparatus comprising: A circular buffer storage circuit for storing a circular buffer including a plurality of slots to hold a queuing sequence of data items; An instruction decoder circuit for decoding instructions; A data processing circuit for performing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to perform an acquisition process to acquire at least one slot in the circular buffer; And A circular buffer metadata storage circuit for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot at one end of the queuing sequence of the data items, and the second reference indicator including an expected slot indicator indicating the expected position of a current slot at the other end of the queuing sequence of the data items, wherein the one end of the queuing sequence of the data items is the head end or the tail end of the queuing sequence of the data items, wherein the instruction decoder circuit responds to a circular buffer fetch instruction to be executed by the data processing circuit to control the data processing circuit to execute the fetch process, the fetch process including the following steps: Attempt to update the second reference indicator of the circular buffer, including an atomic operation in which the number of slots requested to be fetched by the process is compared with the current slot indicator and the expected slot indicator, and When the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for fetching, update the expected slot indicator by modifying the value of the expected slot indicator.

30. A computer program product for controlling a host data processing device to provide an instruction execution environment and comprising: Circular buffer storage logic for storing a circular buffer including a plurality of slots to hold a queuing sequence of data items; Instruction decoder logic for decoding instructions; Data processing logic for executing a plurality of processes to add one or more data items to be processed to the queuing sequence and remove one or more data items from the queuing sequence for processing, wherein each process is arranged to execute a fetch process to fetch at least one slot in the circular buffer; and Circular buffer metadata storage logic for storing metadata of the circular buffer, the metadata including a first reference indicator and a second reference indicator, the first reference indicator including a current slot indicator indicating the position of a current slot at one end of the queuing sequence of the data items, and the second reference indicator including an expected slot indicator indicating the expected position of a current slot at the other end of the queuing sequence of the data items, wherein the one end of the queuing sequence of the data items is the head end or the tail end of the queuing sequence of the data items, wherein the instruction decoder logic responds to a circular buffer fetch instruction to be executed by the data processing logic to control the data processing logic to execute the fetch process, the fetch process including the following steps: Attempt to update the second reference indicator of the circular buffer, including an atomic operation that compares the number of slots requested to be acquired by a process with the current slot indicator and the expected slot indicator, and when the current slot indicator and the expected slot indicator indicate that one or more slots in the circular buffer are eligible for acquisition, update the expected slot indicator by modifying the value of the expected slot indicator.

Citation Information

Patent Citations

  • Bus controller for numerical control system of full digital ring bus

    CN101013311A

  • Integrating a flash cache into large storage systems

    CN102763091A