Head pointer value determination method and device, computer equipment, storage medium and program product

By dynamically updating the head pointer value, the problem of wasted hardware resources caused by determining the request position in a large number of rings is solved. This enables efficient parallel processing and sequential completion of task requests, reduces hardware resource overhead, and improves system throughput.

CN121597436APending Publication Date: 2026-03-03WUXI STARS MICRO SYSTEM TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511695473.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-18
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing technologies result in excessive hardware resource overhead when determining the processing location of requests across a large number of rings.

Method used

By executing task requests in the task queue in parallel and dynamically updating the head pointer value of the preset circular queue according to the head pointer value relationship of the task requests, the head pointer value is ensured to always point to the minimum valid value, thus avoiding duplicate processing and waste of hardware resources.

Benefits of technology

It achieves efficient parallel processing of task requests while maintaining the sequential completion of task requests, reducing hardware resource overhead, avoiding redundant CPU checks, and ensuring high throughput and zero packet loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597436A_ABST
    Figure CN121597436A_ABST
Patent Text Reader

Abstract

The invention relates to a head pointer value determination method and device, computer equipment, a storage medium and a program product. The method comprises the following steps: acquiring at least two task requests carrying head pointer values from a preset annular queue to form a task queue; executing tasks corresponding to the task requests in the task queue in parallel; when the task corresponding to the first request in the task queue is completed, updating a head pointer value of a preset annular queue according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is other requests except the first request in the task queue. By adopting the method, order-preserving completion of the task request can be maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer storage technology, and in particular to a method, apparatus, computer device, storage medium, and program product for determining a head pointer value. Background Technology

[0002] When designing Direct Memory Access (DMA) modules in hardware, hardware-software interaction is often accomplished through ring processing. If multiple requests in the ring need to be processed in parallel, common implementation schemes include fully ordered processing, fully out-of-order processing, and dual-ring processing. Among them, fully out-of-order processing is widely used in the field of high-performance processors (CPUs) due to its high request processing efficiency, high parallelism, and high hardware resource utilization.

[0003] Currently, for completely out-of-order processing, although the completed requests are out of order, the final output or submission must be in the original order of the requests. In order to track which requests have been completed, the system usually uses a bitmap. Each bit of the bitmap corresponds to a slot in the ring. If the task in a slot is completed, the bit corresponding to that slot is set to 1. If the task in a slot is not completed, the bit corresponding to that slot is set to 0. Then, the processing position of the request is determined based on the bitmap.

[0004] However, in some application scenarios, the number of such rings can reach 1,000 or even 10,000. Determining the processing location of a request within such a large number of rings would result in a huge hardware resource overhead. Summary of the Invention

[0005] Therefore, it is necessary to provide a method, apparatus, computer device, storage medium, and program product for determining the head pointer value that can reduce hardware resource overhead when determining the request processing location, in order to address the above-mentioned technical problems.

[0006] Firstly, this application provides a method for determining the value of the head pointer, including:

[0007] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0008] Execute the tasks corresponding to each task request in the task queue in parallel;

[0009] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0010] In one embodiment, updating the head pointer value of the preset circular queue based on the relationship between the head pointer value of the first request and the head pointer value of the second request includes:

[0011] The head pointer value of the first request is compared with the head pointer values ​​of each of the second requests to obtain the comparison results;

[0012] Based on the comparison results, update the head pointer value of the preset circular queue.

[0013] In one embodiment, updating the head pointer value of the preset circular queue based on the comparison result includes:

[0014] If the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then the head pointer value of the first request will be updated to the head pointer value of the preset circular queue.

[0015] If the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0016] In one embodiment, after updating the head pointer value of the first request to the head pointer value of the preset circular queue, the above method further includes:

[0017] Remove the first request from the task queue.

[0018] In one embodiment, after updating the head pointer value of the target request to the head pointer value carried by the first request, the method further includes:

[0019] If the new head value of the target request is the minimum value of the head pointer values ​​of all task requests in the task queue, then the head pointer value of the preset circular queue will be determined as the head pointer value of the target request.

[0020] If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request when the task corresponding to the first request in the task queue is completed.

[0021] In one embodiment, determining the target request from the second request includes:

[0022] The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer value of the first request.

[0023] Secondly, this application also provides a device for determining the value of a head pointer, comprising:

[0024] The acquisition module is used to acquire at least two task requests from a preset circular queue to form a task queue; each task request carries a head pointer value.

[0025] The execution module is used to execute the tasks corresponding to each task request in the task queue in parallel;

[0026] The update module is used to update the head pointer value of the preset circular queue when the task corresponding to the first request in the task queue is completed, based on the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0027] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0028] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0029] Execute the tasks corresponding to each task request in the task queue in parallel;

[0030] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0031] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0032] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0033] Execute the tasks corresponding to each task request in the task queue in parallel;

[0034] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0035] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0036] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0037] Execute the tasks corresponding to each task request in the task queue in parallel;

[0038] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0039] The aforementioned method, apparatus, computer device, storage medium, and program product for determining the head pointer value, when executing multiple task requests in parallel, update the head pointer value of a preset circular queue based on the relationship between the head pointer value of the first request and the head pointer values ​​of other requests in the task queue besides the first request, when the task corresponding to the first request is completed. This ensures that the updated head pointer value of the preset circular queue guarantees that all task requests before (including) the head pointer value are completed, maintaining the ordered completion of task requests. The head pointer value is only globally advanced when it is confirmed that there are no earlier requests that have not been completed; otherwise, it is only partially backfilled. In this way, it fully utilizes the multi-engine concurrency acceleration, ensures strict order preservation at the hardware level, avoids repeated CPU checks, and achieves the beneficial effects of high throughput, zero out-of-order delivery, and zero packet loss. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is an application environment diagram of a method for determining the head pointer value in one embodiment;

[0042] Figure 2This is a flowchart illustrating a method for determining the head pointer value in one embodiment;

[0043] Figure 3 This is a schematic diagram illustrating the acquisition and execution order of task requests in a preset circular queue in one embodiment;

[0044] Figure 4 This is a flowchart illustrating the method for determining the head pointer value in another embodiment;

[0045] Figure 5 This is a flowchart illustrating the method for determining the head pointer value in another embodiment;

[0046] Figure 6 This is a flowchart illustrating the method for determining the head pointer value in another embodiment;

[0047] Figure 7 This is a flowchart illustrating the method for determining the head pointer value in another embodiment;

[0048] Figure 8 This is a schematic diagram illustrating a method for determining the head pointer value in a pre-defined circular queue in one embodiment;

[0049] Figure 9 This is a flowchart illustrating the method for determining the head pointer value in another embodiment;

[0050] Figure 10 This is a structural block diagram of a device for determining the value of the head pointer in one embodiment;

[0051] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0053] When designing Direct Memory Access (DMA) modules in hardware, hardware-software interaction is often accomplished through ring processing. If multiple requests in the ring need to be processed in parallel, common implementation schemes include fully ordered processing, fully out-of-order processing, and dual-ring processing. Among them, fully out-of-order processing is widely used in the field of high-performance processors (CPUs) due to its high request processing efficiency, high parallelism, and high hardware resource utilization.

[0054] Currently, for completely out-of-order processing, although the completed requests are out of order, the final output or submission must be in the original order of the requests. In order to track which requests have been completed, the system usually uses a bitmap. Each bit of the bitmap corresponds to a slot in the ring. If the task in a slot is completed, the bit corresponding to that slot is set to 1. If the task in a slot is not completed, the bit corresponding to that slot is set to 0. Then, the processing position of the request is determined based on the bitmap.

[0055] However, in some applications, the number of such rings can reach 1,000 or even 10,000. Determining the processing location of a request within this large number of rings would result in enormous hardware resource overhead. This application provides a method for determining the head pointer value, aiming to solve the above problem.

[0056] The method for determining the head pointer value provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, the application environment includes a data storage system 102 and a server 104. The data storage system 102 stores the data that the server 104 needs to process. The data storage system 102 can be integrated onto the server 104 or placed on a cloud or other network server. The data storage system 102 includes a data storage structure, into which data can be stored. The data storage structure can be a circular queue, a hash chain, or a hash table, etc. The server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0057] The data storage system 102 can communicate with the server 104. For example, the server 104 can send a data request to the data storage system to retrieve data from the data storage system 102, and then process the retrieved data. It should be noted that after the server 104 retrieves multiple requests from the data storage system and processes the multiple requests in parallel, it needs to output the data in the order in which the requests were retrieved.

[0058] In other possible implementations, the method for determining the head pointer value provided in this application embodiment can also be applied to a terminal. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc.

[0059] It should be noted that the following embodiments include a first request, a second request, and a third request. For the purpose of clearly explaining the various embodiments, the first request, the second request, and the third request in the following embodiments will be explained:

[0060] The first request refers to the request for the completion of a task in a task queue formed by at least two task requests. For example, if the task queue includes three task requests, namely task request 1, task request 2, and task request 3, and the task corresponding to task request 3 is completed, then task request 3 is the first request.

[0061] The second request refers to any other request in the task queue formed by at least two task requests besides the first request. Continuing the previous example, the second request is task request 1 and task request 2.

[0062] The third request refers to a request in which the head pointer values ​​of the second request are all less than the head pointer value of the first request. Continuing with the previous example, if the head pointer value of task request 1 is less than the head pointer value of task request 3 (the first request), then the third request is task request 1.

[0063] In one exemplary embodiment, such as Figure 2 As shown, a method for determining the value of the head pointer is provided, and this method is applied to... Figure 1 Taking server 104 as an example, the explanation includes:

[0064] S201. Obtain at least two task requests from the preset circular queue to form a task queue; the task request carries a head pointer value.

[0065] A pre-defined circular queue refers to a circular storage space used to store task requests; it is a data structure type. A pre-defined circular queue can be a circular buffer. A pre-defined circular queue can be used... Figure 3 This indicates that the preset circular queue includes multiple circular blocks, each corresponding to a head pointer value, and the head pointer values ​​of consecutive circular blocks are consecutive.

[0066] It should be noted that task requests can be pre-stored in each circular block of the preset circular queue. When the server retrieves a task request from the preset circular queue, the task request can carry the head pointer value of the corresponding circular block. For example, if the server retrieves task request rd_1 from the preset circular queue, since the head pointer value of the circular block corresponding to task request rd_1 is 11, then the task request rd_1 retrieved by the server can carry the head pointer value 11. As another example, if the server retrieves task request rd_5 from the preset circular queue, since the head pointer value of the circular block corresponding to task request rd_5 is 15, then the task request rd_5 retrieved by the server can carry the head pointer value 15.

[0067] Among them, at least two task requests carry consecutive head pointer values. For example, if the server needs to retrieve 5 task requests from a preset circular queue, then the head pointer values ​​corresponding to these 5 task requests can be: 11, 12, 13, 14 and 15 respectively.

[0068] In this embodiment, in order to achieve efficient processing of task requests, at least two task requests carrying head pointer values ​​can be obtained from a preset circular queue at one time, and at least two task requests form a task queue.

[0069] It should be noted that when the server retrieves task requests in batches from a pre-defined circular queue, these batched task requests can form a task queue. Generally, the server retrieves task requests from the pre-defined circular queue in order of the head pointer values ​​of the circular blocks. For example, if the server needs to retrieve 8 task requests from the pre-defined circular queue, it can retrieve the task requests corresponding to pointer values ​​11-18, and these 8 task requests form a task queue. Alternatively, if the server has processed the task requests up to pointer value 19 and now needs to retrieve 7 task requests from the pre-defined circular queue, it can retrieve the task requests corresponding to pointer values ​​19-25, and these 7 task requests form a task queue.

[0070] S202. Execute the tasks corresponding to each task request in the parallel task queue.

[0071] In this embodiment, after obtaining a task queue formed by at least two task requests, the server can execute the tasks corresponding to each task request in the task queue in parallel. Since the amount of tasks corresponding to each task request is different, the completion time of each task request may be different. For example, please continue to see... Figure 3When executing tasks in a task queue with 8 task requests in parallel, the execution order of the tasks can be as follows: cp_1 (task request: rd_1, head pointer value: 11), cp_2 (task request: rd_6, head pointer value: 16), cp_3 (task request: rd_8, head pointer value: 18), cp_4 (task request: rd_3, head pointer value: 13), cp_5 (task request: rd_6, head pointer value: 16), cp_6 (task request: rd_4, head pointer value: 14), cp_7 (task request: rd_7, head pointer value: 17), and cp_8 (task request: rd_5, head pointer value: 15).

[0072] It should be noted that when cp_1 completes, the head pointer value of the preset circular queue can be directly corrected to 11 to inform the server (or other nodes) that all task requests corresponding to head pointer values ​​up to and including head pointer value 11 in the preset circular queue have been completed. This maintains the ordered completion of task requests. However, when cp_2 completes, if the head pointer value of the preset circular queue is directly corrected to 16 to inform the server (or other nodes) that all task requests corresponding to head pointer values ​​up to and including head pointer value 16 in the preset circular queue have been completed, but in reality, the task requests corresponding to head pointer values ​​12, 13, 14, and 15 have not been completed, this obviously cannot maintain the ordered completion of task requests. Therefore, the following provides a method to maintain the ordered completion of task requests based on the size of the head pointer value of each task request.

[0073] S203. When the task corresponding to the first request in the task queue is completed, update the head pointer value of the preset circular queue according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0074] The first request refers to the request for the completion of a task in a task queue formed by at least two task requests. For example, if the task queue includes three task requests, namely task request 1, task request 2, and task request 3, then task request 3 is the first request if the task corresponding to task request 3 is completed.

[0075] The second request refers to any request other than the first request in a task queue formed by at least two task requests. Continuing with the previous example, the second request is task request 1 and task request 2.

[0076] In this embodiment, when the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue can be updated according to the relationship between the head pointer value of the first request and the head pointer values ​​of other requests in the task queue besides the first request.

[0077] Optionally, after the task corresponding to the first request is completed, the head pointer values ​​of all task requests in the task queue can be sorted by size to obtain the head pointer values ​​of each task request after sorting. If the head pointer value corresponding to the first request is the minimum value among the head pointer values ​​of each task request after sorting, then the head pointer value corresponding to the first request is directly determined as the head pointer value of the preset circular queue.

[0078] Optionally, after the task corresponding to the first request is completed, the head pointer value corresponding to the first request can be compared with the head pointer values ​​of other requests in the task queue. If the head pointer value corresponding to the first request is smaller than the head pointer values ​​of other requests in the task queue, then the head pointer value corresponding to the first request can be directly determined as the head pointer value of the preset circular queue.

[0079] Optionally, if the head pointer value corresponding to the first request is not the minimum head pointer value among all task requests in the task queue, then the head pointer value of the preset circular queue may not be updated, ensuring that the head pointer value of the preset circular queue remains unchanged. For example, if the first request is cp_2, its corresponding head pointer value is 16. Pointer value 16 is not the smallest among pointer values ​​12, 13, 14, 15, 17, and 18. Therefore, the head pointer value of the preset circular queue is not updated, and the head pointer value of the preset circular queue remains at head pointer value 11, indicating that the task request corresponding to the position before (including head pointer value 11) has been completed.

[0080] In this embodiment, when multiple task requests are executed in parallel, if the task corresponding to the first request is completed, the head pointer value of the preset circular queue is updated based on the relationship between the head pointer value of the first request and the head pointer values ​​of other requests in the task queue. This ensures that the updated head pointer value of the preset circular queue guarantees that all task requests before (including) the head pointer value are completed, thus maintaining the ordered completion of task requests. The head pointer value is only globally advanced when it is confirmed that there are no earlier requests that have not been completed. Otherwise, only local backfilling is performed. In this way, the multi-engine concurrency acceleration is fully utilized, and strict order preservation at the hardware level is guaranteed, avoiding repeated CPU checks and achieving the beneficial effects of high throughput, zero out-of-order delivery, and zero packet loss.

[0081] In this embodiment, in the above Figure 2 Based on the illustrated embodiment, the detailed process of updating the head pointer value of the preset circular queue based on the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request will be explained. In an exemplary embodiment, such as Figure 4 As shown, the above S203 includes:

[0082] S301. Compare the head pointer value of the first request with the head pointer value of each second request to obtain the comparison result.

[0083] In this embodiment, when the task corresponding to the first request in the task queue is completed, the head pointer value of the first request can be compared with the head pointer values ​​of each second request to obtain the comparison result; optionally, the comparison result may be that the head pointer value of the first request is the minimum value among the head values ​​of each task request in the task queue, or the comparison result may be that the head pointer value of the first request is not the minimum value among the head pointer values ​​of each task request in the task queue.

[0084] S302. Based on the comparison results, update the head pointer value of the preset circular queue.

[0085] In this embodiment, after obtaining the comparison result, the head pointer value of the preset circular queue can be updated according to the comparison result.

[0086] Optionally, if the comparison result is that the head pointer value of the first request is the minimum head value among all the head requests in the task queue, then the first method for updating the head pointer value of the preset circular queue is used; alternatively, if the comparison result is that the head pointer value of the first request is not the minimum head pointer value among all the task requests in the task queue, then the second method for updating the head pointer value of the preset circular queue is used.

[0087] Optionally, the following provides a specific implementation method for updating the head pointer value of a preset circular queue based on the comparison result, such as... Figure 5 As shown, i.e., S302 above, includes:

[0088] S3021. If the comparison result shows that the head pointer value of the first request is the minimum head value among all task requests in the task queue, then update the head pointer value of the first request to the head pointer value of the preset circular queue.

[0089] In this embodiment, if the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then the head pointer value of the first request is directly updated to the head pointer value of the preset circular queue.

[0090] For example, please continue to see Figure 3 If the first request is cp_1, and the head pointer value corresponding to the first request cp_1 is 11, which is the minimum value of the head pointer values ​​corresponding to all task requests in the task queue, then the head pointer value 11 of the first request is directly updated to the head pointer value of the preset circular queue to indicate that all task requests before (including head pointer value 11) are completed, thus maintaining the ordered completion of task requests.

[0091] S3022. If the comparison result is that the head pointer value of the first request is not the minimum value among the head pointer values ​​of each task request in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0092] The process of determining the target request from the second request may include:

[0093] The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer values ​​of the first request. For example, please see [link to example]. Figure 3If the first request is cp_2, and the head pointer value corresponding to the first request cp_2 is 16, which is not the minimum head pointer value among all the task requests in the task queue, then it is necessary to determine the third request from the other requests in the task queue besides the first request cp_2. That is, first determine the requests whose head pointer value is less than the head pointer value 16, including: task request cp_8 corresponding to head pointer value 15, task request cp_6 corresponding to head pointer value 14, task request cp_4 corresponding to head pointer value 13, and task request cp_5 corresponding to head pointer value 12. Then, determine the task request with the largest head pointer value from these task requests as the target request, that is, task request cp_8 corresponding to head pointer value 15 as the target request.

[0094] Furthermore, after determining the target request, the head pointer value of the target request can be updated to the head pointer value carried by the first request. Continuing with the previous example, the head pointer value 15 of task request cp_8 can be updated to the head pointer value 16. At this time, there is no need to update the head pointer value of the preset circular queue, because not all task requests before head pointer value 16 (including head pointer value 16) have been completed.

[0095] In this embodiment, by dynamically comparing the head pointer values ​​of each request in the task queue, it is ensured that the head pointer of the circular queue always points to the smallest valid value, thereby avoiding data overwriting or duplicate processing, and improving the system resource utilization efficiency and task processing accuracy.

[0096] In this embodiment, in the above Figure 5 Based on the embodiments shown, such as Figure 6 As shown, after updating the head pointer value of the first request to the head pointer value of the preset circular queue, the above method further includes:

[0097] S3023. Remove the first request from the task queue.

[0098] In this embodiment, after updating the head pointer value of the first request to the head pointer value of the preset circular queue, the first request can be directly deleted from the task queue. This avoids the situation where, when processing the next request, the head pointer value of the first request is always determined when determining the minimum head pointer value from all the head pointer values ​​corresponding to all task requests in the task queue due to the existence of the first request.

[0099] For example, please continue to see Figure 3After updating the head pointer value of the first request (11) to the head pointer value of the preset circular queue, the first request (cp_1) can be deleted from the task queue. Thus, after task request (cp_2) is completed, it can be determined from the updated task queue whether the head pointer value of task request (cp_2) is the minimum among all the head pointer values ​​of all task requests. However, if the first request (cp_1) is not deleted from the task queue, it is impossible to determine whether the head pointer value of task request (cp_2) is the minimum among all the head pointer values ​​of all task requests, regardless of whether the head pointer value of task request (cp_2) is 12.

[0100] In this embodiment, by updating the head pointer value of the first request to the head pointer value of the preset circular queue and then deleting the first request from the task queue, the queue slots can be reclaimed in time, the risk of duplicate processing can be eliminated, thereby improving task scheduling efficiency and system resource utilization.

[0101] In this embodiment, in the above Figure 5 Based on the embodiments shown, such as Figure 7 As shown, after updating the head pointer value of the target request to the head pointer value carried by the first request, the above method further includes:

[0102] S3024. If the new head value of the target request is the minimum value of the head pointer values ​​of each task request in the task queue, then the head pointer value of the circular queue is determined as the head pointer value of the target request.

[0103] In this embodiment, after updating the head pointer value of the target request to the head pointer value carried by the first request, if the new head value of the target request is the minimum value of the head pointer values ​​of each task request in the task queue, then the head pointer value of the circular queue is determined as the head pointer value of the target request.

[0104] For example, see Figure 8If the first request is cp_4, and the head pointer value corresponding to the first request cp_4 is 13, based on the above method, after updating the head pointer value of the target request cp_5 from 12 to the head pointer value of 13 carried by the first request cp_4, the new head pointer value of the target request cp_5 is 13, which is exactly the head pointer value of each task request in the task queue (based on the above description, after deleting task request cp_1 from the task queue, the task queue includes: task request cp_2, task request cp_3, task request cp_4, task request cp_5, task request cp_6, task request cp_7, and task request cp_8). Find the minimum value among the following: cp_2 (head pointer value is 16), cp_3 (head pointer value is 18), cp_4 (head pointer value is 13), cp_5 (head pointer value is 13), cp_6 (head pointer value is 14), cp_7 (head pointer value is 18), and cp_8 (head pointer value is 18). Then, the head pointer value of the preset circular queue is set to the head pointer value of the target request (13), indicating that all task requests before (including) head pointer value 13 are completed, thus maintaining the ordered completion of task requests.

[0105] Furthermore, after determining the head pointer value of the preset circular queue as the head pointer value 13 of the target request, the task request cp_5 corresponding to the head pointer value 13, as well as the task requests between task request cp_5 and task request cp_1, can be deleted from the task queue.

[0106] S3025. If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the point where the task corresponding to the first request in the task queue is completed, and update the head pointer value of the preset circular queue according to the relationship between the head pointer value of the first request and the head pointer value of the second request.

[0107] In this embodiment, please continue to refer to Figure 8If the first request is cp_3, and the head pointer value corresponding to the first request cp_3 is 18, after the first request cp_3 is completed, based on the above method, the head pointer value of the target request cp_7 is updated from 17 to the head pointer value of 18 carried by the first request cp_3. The new head pointer value of the target request cp_7 is 18, which is not one of the tasks in the task queue (based on the above description, after deleting task request cp_1 from the task queue, the task queue includes: task requests cp_2, cp_3, cp_4, cp_5, cp_6, cp_7, and cp_8). If the minimum head pointer value among the requested head pointer values ​​(head pointer value of task request cp_2 is 16, head pointer value of task request cp_3 is 18, head pointer value of task request cp_4 is 13, head pointer value of task request cp_5 is 13, head pointer value of task request cp_6 is 14, head pointer value of task request cp_7 is 18, and head pointer value of task request cp_8 is 18) is found, then it is necessary to continue waiting for the next first request to complete, and then continue to update the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the second request. For example, after task request cp_7 is completed, the target request cp_8 can be determined again, and the head pointer value of task request cp_8 can be updated from 16 to 18. After task request cp_8 is completed, all requests in the task queue are completed, that is, the head pointer value of the preset circular queue is updated to 18, indicating that all task requests before head pointer value 18 (including head pointer value 18) are completed.

[0108] In this embodiment, the minimum head pointer value is used as the criterion. The target request first determines the latest head pointer value of the circular queue in one go. If the minimum value is not reached, the request is retried immediately. This can quickly converge to the global minimum effective head pointer value, ensuring that the queue head pointer always points to the earliest position to be processed, avoiding data gaps and duplicate processing, and improving the security and throughput efficiency of the circular buffer.

[0109] In one embodiment, see Figure 9 It also provides a method for determining the value of the head pointer, including:

[0110] T1. Obtain at least two task requests from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0111] T2. Execute the tasks corresponding to each task request in the parallel task queue;

[0112] T3. When the task corresponding to the first request in the task queue is completed, the head pointer value of the first request is compared with the head pointer values ​​of each second request to obtain the comparison result; the second requests are all other requests in the task queue except for the first request.

[0113] T4. If the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then update the head pointer value of the first request to the head pointer value of the preset circular queue.

[0114] T5. Remove the first request from the task queue;

[0115] T6. If the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all the task requests in the task queue, then the target request is determined from the second request. The target request is the request with the largest head pointer value in the third request. The third request includes requests in the second request whose head pointer values ​​are all less than the head pointer value of the first request.

[0116] T7. Update the head pointer value of the target request to the head pointer value carried by the first request. If the new head value of the target request is the minimum head pointer value of each task request in the task queue, then determine the head pointer value of the preset circular queue as the head pointer value of the target request.

[0117] T8. If the new head value requested by the target is not the minimum head pointer value of each task request in the task queue, then return to execute T3-T7.

[0118] It should be noted that the descriptions of T1-T8 above can be found in the relevant descriptions in the above embodiments, and their effects are similar, so they will not be repeated here.

[0119] For example, please continue to see Figure 8 The method for determining the head pointer value provided in this application is illustrated below with examples:

[0120] Step 1: The server retrieves task requests from the preset circular queue in the order of task requests rd_1->rd_8; each task request carries a head pointer value.

[0121] Step 2: If the head pointer value corresponding to task request cp_1 is 11, and the head pointer value corresponding to task request cp_1 is 11, which is the smallest pointer value among the head pointer values ​​corresponding to task request rd_1->rd_8, then update the head pointer value of the preset circular queue to 11.

[0122] Step 3: If the head pointer value 16 corresponding to task request cp_2 is completed, and the head pointer value 15 is the largest queue in the queue that is smaller than the head pointer value 16 corresponding to task request cp_2, then update the head pointer value 15 corresponding to task request cp_8 to the head pointer value 16.

[0123] Step 4: If the head pointer value 18 corresponding to task request cp_3 is completed, and the head pointer value 17 is the largest queue in the queue that is smaller than the head pointer value 18 corresponding to task request cp_3, then update the head pointer value 17 corresponding to task request cp_7 to the head pointer value 18.

[0124] Step 5: If the head pointer value 13 corresponding to task request cp_4 is completed, and the head pointer value 12 is the largest queue in the queue that is smaller than the head pointer value 13 corresponding to task request cp_4, then update the head pointer value 12 corresponding to task request cp_5 to the head pointer value 13.

[0125] Step 6: If the head pointer value corresponding to task request cp_5 is 13 (the head pointer value is 12 when the request is retrieved), and the head pointer value 13 is the smallest pointer value among the head pointer values ​​corresponding to rd_2->rd_8, then update the head pointer value of the preset circular queue to 13.

[0126] Step 7: If the head pointer value corresponding to cp_6 is 14 when the task request is completed, and the head pointer value 14 is the smallest pointer value among the head pointer values ​​corresponding to rd_6->rd_8, then update the head pointer value of the preset circular queue to 14.

[0127] Step 8: If the head pointer value corresponding to cp_7 is 18 (head pointer value is 17 when the request is retrieved), and the head pointer value is not the smallest pointer value among the head pointer values ​​corresponding to rd_7->rd_8, then the head pointer value is updated to 14 along with the head value 16 (head pointer value is 15 when the request is retrieved).

[0128] Step 9: If the head pointer value corresponding to task request cp_8 is 18 (the head pointer value is 15 when the request is retrieved), and the head pointer value is the largest head pointer value, then update the head pointer value of the preset circular queue to 18.

[0129] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0130] Based on the same inventive concept, this application also provides a head pointer value determination apparatus for implementing the head pointer value determination method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more head pointer value determination apparatus embodiments provided below can be found in the limitations of the head pointer value determination method described above, and will not be repeated here.

[0131] In one exemplary embodiment, such as Figure 10 As shown, a device for determining the value of a head pointer is provided, comprising: an acquisition module 10, an execution module 11, and an update module 12, wherein:

[0132] The acquisition module 10 is used to acquire at least two task requests from a preset circular queue to form a task queue; the task requests carry a head pointer value.

[0133] Execution module 11 is used to execute the tasks corresponding to each task request in the task queue in parallel.

[0134] The update module 12 is used to update the head pointer value of the preset circular queue according to the relationship between the head pointer value of the first request and the head pointer value of the second request when the task corresponding to the first request in the task queue is completed; the second request is any other request in the task queue besides the first request.

[0135] In an exemplary embodiment, the update module 12 includes:

[0136] The comparison unit is specifically used to compare the head pointer value of the first request with the head pointer values ​​of each second request to obtain the comparison result;

[0137] The update unit is specifically used to update the head pointer value of the preset circular queue based on the comparison result.

[0138] In an exemplary embodiment, the above-mentioned updating unit is further configured to: if the comparison result shows that the head pointer value of the first request is the minimum head value among all task requests in the task queue, then update the head pointer value of the first request to the head pointer value of the preset circular queue; if the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then determine the target request from the second request and update the head pointer value of the target request to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0139] In one exemplary embodiment, the above-mentioned update unit is further configured to delete the first request from the task queue.

[0140] In an exemplary embodiment, the above-mentioned updating unit is further configured to: if the new head value of the target request is the minimum value of the head pointer values ​​of each task request in the task queue, then determine the head pointer value of the preset circular queue as the head pointer value of the target request; if the new head value of the target request is not the minimum value of the head pointer values ​​of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer value of the first request and the head pointer value of the second request when the task corresponding to the first request in the task queue is completed.

[0141] In an exemplary embodiment, the aforementioned updating unit is further configured to determine the request with the largest head pointer value in the third request as the target request; the third request includes requests in the second request whose head pointer values ​​are all less than the head pointer value of the first request.

[0142] Each module in the aforementioned head pointer value determination device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0143] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores task request data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a method for determining the value of a head pointer.

[0144] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0145] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0146] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0147] Execute the tasks corresponding to each task request in the task queue in parallel;

[0148] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0149] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0150] The head pointer value of the first request is compared with the head pointer values ​​of each of the second requests to obtain the comparison results;

[0151] Based on the comparison results, update the head pointer value of the preset circular queue.

[0152] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0153] If the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then the head pointer value of the first request will be updated to the head pointer value of the preset circular queue.

[0154] If the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0155] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0156] Remove the first request from the task queue.

[0157] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0158] If the new head value of the target request is the minimum value of the head pointer values ​​of all task requests in the task queue, then the head pointer value of the preset circular queue will be determined as the head pointer value of the target request.

[0159] If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request when the task corresponding to the first request in the task queue is completed.

[0160] In one embodiment, the processor, when executing a computer program, also performs the following steps:

[0161] The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer value of the first request.

[0162] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0163] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0164] Execute the tasks corresponding to each task request in the task queue in parallel;

[0165] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0166] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0167] The head pointer value of the first request is compared with the head pointer values ​​of each of the second requests to obtain the comparison results;

[0168] Based on the comparison results, update the head pointer value of the preset circular queue.

[0169] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0170] If the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then the head pointer value of the first request will be updated to the head pointer value of the preset circular queue.

[0171] If the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0172] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0173] Remove the first request from the task queue.

[0174] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0175] If the new head value of the target request is the minimum value of the head pointer values ​​of all task requests in the task queue, then the head pointer value of the preset circular queue will be determined as the head pointer value of the target request.

[0176] If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request when the task corresponding to the first request in the task queue is completed.

[0177] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0178] The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer value of the first request.

[0179] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0180] At least two task requests are retrieved from a pre-defined circular queue to form a task queue; each task request carries a head pointer value.

[0181] Execute the tasks corresponding to each task request in the task queue in parallel;

[0182] When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

[0183] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0184] The head pointer value of the first request is compared with the head pointer values ​​of each of the second requests to obtain the comparison results;

[0185] Based on the comparison results, update the head pointer value of the preset circular queue.

[0186] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0187] If the comparison result shows that the head pointer value of the first request is the minimum head value among all the task requests in the task queue, then the head pointer value of the first request will be updated to the head pointer value of the preset circular queue.

[0188] If the comparison result shows that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

[0189] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0190] Remove the first request from the task queue.

[0191] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0192] If the new head value of the target request is the minimum value of the head pointer values ​​of all task requests in the task queue, then the head pointer value of the preset circular queue will be determined as the head pointer value of the target request.

[0193] If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request when the task corresponding to the first request in the task queue is completed.

[0194] In one embodiment, when the computer program is executed by a processor, it further performs the following steps:

[0195] The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer value of the first request.

[0196] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0197] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0198] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for determining the value of a head pointer, characterized in that, The method includes: At least two task requests are obtained from a preset circular queue to form a task queue; each task request carries a head pointer value. The tasks corresponding to each task request in the task queue are executed in parallel. When the task corresponding to the first request in the task queue is completed, the head pointer value of the preset circular queue is updated according to the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

2. The method according to claim 1, characterized in that, The step of updating the head pointer value of the preset circular queue based on the relationship between the head pointer value of the first request and the head pointer value of the second request includes: The head pointer value of the first request is compared with the head pointer value of each of the second requests to obtain the comparison result; Based on the comparison result, update the head pointer value of the preset circular queue.

3. The method according to claim 2, characterized in that, The step of updating the head pointer value of the preset circular queue based on the comparison result includes: If the comparison result is that the head pointer value of the first request is the minimum value among the head values ​​of each task request in the task queue, then the head pointer value of the first request is updated to the head pointer value of the preset circular queue. If the comparison result is that the head pointer value of the first request is not the minimum head pointer value among all task requests in the task queue, then the target request is determined from the second request, and the head pointer value of the target request is updated to the head pointer value carried by the first request, so as to determine the head pointer value of the preset circular queue.

4. The method according to claim 3, characterized in that, After updating the head pointer value of the first request to the head pointer value of the preset circular queue, the method further includes: Remove the first request from the task queue.

5. The method according to claim 4, characterized in that, After updating the head pointer value of the target request to the head pointer value carried by the first request, the method further includes: If the new head value of the target request is the minimum value of the head pointer values ​​of all task requests in the task queue, then the head pointer value of the preset circular queue is determined as the head pointer value of the target request. If the new head value of the target request is not the minimum head pointer value of each task request in the task queue, then return to the step of updating the head pointer value of the preset circular queue according to the relationship between the head pointer values ​​of the first request and the head pointer values ​​of the second request when the task corresponding to the first request in the task queue is completed.

6. The method according to claim 3, characterized in that, Determining the target request from the second request includes: The request with the largest head pointer value in the third request is identified as the target request; the third request includes requests in the second request whose head pointer values ​​are all smaller than the head pointer value of the first request.

7. A device for determining the value of a head pointer, characterized in that, The device includes: The acquisition module is used to acquire at least two task requests from a preset circular queue to form a task queue; the task request carries a head pointer value; The execution module is used to execute the tasks corresponding to each task request in the task queue in parallel; An update module is used to update the head pointer value of the preset circular queue when the task corresponding to the first request in the task queue is completed, based on the relationship between the head pointer value of the first request and the head pointer value of the second request; the second request is any other request in the task queue besides the first request.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.