Task data queue control method and system

By employing a multi-buffer circular queue design and dynamic filling aggregation in SPI communication, the problems of low buffer utilization and high bus conflict are solved, achieving efficient and reliable data transmission and ensuring the real-time performance and system stability of high-priority tasks.

CN121509352APending Publication Date: 2026-02-10CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511647443.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-11
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Traditional SPI communication schemes suffer from low buffer utilization, high memory consumption, high probability of bus conflicts, poor real-time performance, and cannot effectively guarantee the real-time performance and reliability of high-priority tasks.

Method used

A circular queue design with multiple buffers is adopted, with each buffer configured with storage space of different priorities. Through dynamic filling and data aggregation, priority-based storage and transmission of task data are achieved, ensuring that high-priority tasks are processed before low-priority tasks. The multi-buffer redundancy design also supports retrying in case of transmission failure.

Benefits of technology

It improves buffer utilization, reduces memory usage, suppresses bus conflicts, enhances the real-time performance and reliability of data transmission, reduces data loss rate, and improves system reliability and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121509352A_ABST
    Figure CN121509352A_ABST
Patent Text Reader

Abstract

The invention provides a task data queue control method and system, and relates to the technical field of communication. The task data queue control method comprises the following steps: initializing a circular queue of a plurality of buffer areas, wherein the buffer areas comprise first task data intervals and second task data intervals; performing circular queue traversal according to the plurality of buffer areas, and performing the following processing on the traversed current buffer area: obtaining at least one piece of to-be-sent task data; determining a priority type of the to-be-sent task data; storing the to-be-sent task data to the first task data interval or the second task data interval according to the priority type of the to-be-sent task data; sending the task data of the current buffer area; and switching to the next buffer area in the circular queue. According to the task data queue control method, the technical effect of improving the real-time performance and reliability of data transmission can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communication technology, and more specifically, to a control method and system for a task data queue. Background Technology

[0002] In the field of wireless communication, SPI (Serial Peripheral Interface) communication is widely used in wireless communication systems for multiple terminal devices. On these devices, the high-speed, short-range wired connection between the main chip and the wireless communication module requires the transmission of various periodic task data via SPI communication. Currently, traditional SPI communication schemes typically employ a single-buffer design, which suffers from the following problems: low buffer utilization, high memory consumption, and high probability of bus collisions, resulting in poor real-time performance and low reliability. Summary of the Invention

[0003] The purpose of this application is to provide a control method, system, electronic device, and computer-readable storage medium for a task data queue, which can achieve the technical effect of improving the real-time performance and reliability of data transmission.

[0004] Firstly, this application provides a method for controlling a task data queue, including: Initialize a circular queue of multiple buffers, wherein the buffers include a first task data range and a second task data range; The multiple buffers are traversed in a circular queue, and the current buffer encountered during the traversal is processed as follows: Acquire at least one task data to be sent; Determine the priority type of the task data to be sent; The task data to be sent is stored in the first task data range or the second task data range according to the priority type of the task data to be sent. Send the task data in the current buffer; Switch to the next buffer in the circular queue.

[0005] In the above implementation, a circular queue of multiple buffers is used to achieve a cyclical flow of processing states between filling, sending, and ready. That is, after one buffer is filled, data is sent, the next buffer begins to be filled, and other buffers are in a ready state, thus achieving dynamic filling. At the same time, each buffer is configured with storage space of different priorities, which can store task data of different priorities respectively. A single buffer can include aggregated task data of multiple priorities. Therefore, the task data queue control method reduces the number of transmissions, improves buffer utilization and reduces memory consumption, suppresses bus conflicts, and enhances real-time performance through dynamic filling and data aggregation, thereby achieving the technical effect of improving the real-time performance and reliability of data transmission.

[0006] Further, the priority type includes a first priority and a second priority, and the first priority is greater than the second priority. The step of storing the task data to be sent into the first task data range or the second task data range according to the priority type includes: If the priority type of the task data to be sent is the first priority, the task data to be sent is stored in the first task data range; If the priority type of the task data to be sent is the second priority, the task data to be sent is stored in the second task data range.

[0007] In the above implementation process, among the priority types of task data, the first priority is high priority and the second priority is low priority. When filling data, the data is filled into the corresponding task data intervals according to the priority. Thus, the task data is filled into the corresponding task data intervals according to the insertion priority of the task data itself. Each task data interval contains task data of the same priority, avoiding priority confusion caused by tasks of different priorities being mixed in the sending queue of a buffer.

[0008] Further, the step of storing the task data to be sent into the first task data range includes: Obtain the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the first task data range in sequence according to the storage order.

[0009] In the above implementation process, the first task data interval stores task data of the same priority. At this time, the task data to be sent is arranged according to the arrival time information and filled into the first task data interval in sequence to avoid chaotic filling of task data.

[0010] Further, the step of storing the task data to be sent into the second task data range includes: Obtain the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the second task data range in sequence according to the storage order.

[0011] In the above implementation process, the second task data interval stores task data of the same priority. At this time, the task data to be sent is arranged according to the arrival time information and filled into the second task data interval in sequence to avoid chaotic filling of task data.

[0012] Further, the first task data interval and the second task data interval are configured sequentially along the data reading direction, and the step of sending the task data of the current buffer includes: Send the task data within the first task data range in the current buffer; After the task data within the first task data range is sent, the task data within the second task data range is sent.

[0013] In the above implementation process, during the sending of task data in the buffer, the sending order is from the first task data interval to the second task data interval in sequence, ensuring that high-priority task data is processed before low-priority task data, thus avoiding the problem that high-priority tasks may be blocked by low-priority tasks for a long time.

[0014] Furthermore, prior to the step of sending the task data in the current buffer, the method further includes: Obtain the remaining space in the current buffer; If the data capacity of the remaining space is greater than or equal to the data length of the task data to be sent, then return to the step of obtaining at least one task data to be sent.

[0015] In the above implementation process, when the current buffer is not completely filled and there is still space to receive new task data, the buffer can continue to receive new task data to be sent, ensuring the utilization rate of the buffer. This can effectively solve the problems of low buffer utilization and high memory consumption in traditional single buffer designs.

[0016] Furthermore, prior to the step of sending the task data in the current buffer, the method further includes: Obtain the dwell time of the current buffer; If the dwell time of the current buffer is greater than or equal to a preset time threshold, then the step of sending the task data of the current buffer is executed.

[0017] In the above implementation process, if the buffer is not filled and there is still space remaining, but the dwell time exceeds the preset time threshold, the transmission is forcibly triggered to send the task data of the current buffer in order to avoid the accumulation of delay.

[0018] Further, the step of sending the task data in the current buffer includes: Obtain the status information of the transmission interface; If the status information of the transmission interface is idle, then the task data of the current buffer is submitted to the transmission interface; The task data of the current buffer is sent through the transmission interface.

[0019] In the above implementation process, by querying the status information of the transmission interface, after confirming that the transmission interface is in an idle state, the task data in the current buffer is submitted for transmission, and then switched to the next idle buffer for filling, ensuring the thread safety of state switching, avoiding data overwriting, and improving reliability and stability.

[0020] Furthermore, after the step of sending the task data in the current buffer, the method further includes: Obtain the data transmission result; If the data transmission fails, the task data in the current buffer is retained, and the current buffer is either placed at the end of the circular queue or inserted after the next buffer.

[0021] In the above implementation process, when the task data transmission fails, the redundant design of multiple buffers supports retrying the transmission failure, which can effectively reduce the data packet loss rate and effectively solve the problems of data packet loss and poor fault tolerance after the traditional single buffer design is exhausted.

[0022] Secondly, this application provides a control system for a task data queue, comprising: An initialization module is used to initialize a circular queue of multiple buffers, wherein the buffers include a first task data range and a second task data range; The processing module is used to perform circular queue traversal based on the multiple buffers, and to perform the following processing on the current buffer being traversed: obtain at least one task data to be sent; determine the priority type of the task data to be sent; store the task data to be sent in the first task data range or the second task data range according to the priority type of the task data to be sent; send the task data in the current buffer; and switch to the next buffer in the circular queue.

[0023] Furthermore, the priority type includes a first priority and a second priority, and the first priority is greater than the second priority. The processing module is also used to: if the priority type of the task data to be sent is the first priority, store the task data to be sent in the first task data range; if the priority type of the task data to be sent is the second priority, store the task data to be sent in the second task data range.

[0024] Furthermore, the processing module is also configured to: obtain the arrival time information of the task data to be sent; determine the storage order according to the arrival time information; and store the task data to be sent into the first task data range in sequence according to the storage order.

[0025] Furthermore, the processing module is also configured to: obtain the arrival time information of the task data to be sent; determine the storage order according to the arrival time information; and store the task data to be sent into the second task data range in sequence according to the storage order.

[0026] Furthermore, the first task data interval and the second task data interval are configured sequentially along the data reading direction, and the processing module is also used to: send task data in the first task data interval in the current buffer; and after the task data in the first task data interval is sent, send task data in the second task data interval.

[0027] Furthermore, the processing module is also configured to: obtain the remaining space of the current buffer; if the data capacity of the remaining space is greater than or equal to the data length of the task data to be sent, then return to the step of obtaining at least one task data to be sent.

[0028] Furthermore, the processing module is also configured to: obtain the dwell time of the current buffer; if the dwell time of the current buffer is greater than or equal to a preset time threshold, then execute the step of sending the task data of the current buffer.

[0029] Furthermore, the processing module is also configured to: obtain the status information of the transmission interface; if the status information of the transmission interface is idle, submit the task data of the current buffer to the transmission interface; and send the task data of the current buffer through the transmission interface.

[0030] Furthermore, the processing module is also used to: obtain the data transmission result; if the data transmission result fails, retain the task data of the current buffer, place the current buffer at the tail of the circular queue, or insert the current buffer after the next buffer.

[0031] Thirdly, this application provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method described in any of the first aspects.

[0032] Fourthly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the method described in any of the first aspects.

[0033] Fifthly, this application provides a computer program product that, when run on a computer, causes the computer to perform the method described in any of the first aspects.

[0034] Other features and advantages disclosed in this application will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the above-described technology disclosed in this application.

[0035] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0036] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 A flowchart illustrating a task data queue control method provided in an embodiment of this application; Figure 2 A flowchart illustrating another method for controlling a task data queue provided in an embodiment of this application; Figure 3 This is a schematic diagram of the process for sending task data in the current buffer, provided in an embodiment of this application. Figure 4 A structural block diagram of the control system for the task data queue provided in the embodiments of this application; Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0038] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0039] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0040] Generally, in the field of wireless communication, SPI (Serial Peripheral Interface) communication is widely used in wireless communication systems with multiple terminal devices. On these devices, the high-speed, short-range wired connection between the main chip and the wireless communication module requires the transmission of various periodic task data via SPI communication. Traditional SPI communication schemes typically employ a single-buffer design, which suffers from the following problems: low buffer utilization and high memory consumption; high probability of bus collisions and poor real-time performance; data loss after buffer exhaustion, resulting in poor fault tolerance and low reliability.

[0041] Currently, there are some improvements to the traditional SPI communication scheme, such as multi-buffer design and dynamic data aggregation, but certain shortcomings still exist. For example, although multi-buffer design improves buffer utilization, a single buffer can only store task data once, and the order of buffer usage cannot be dynamically adjusted according to task priority, which may cause high-priority tasks to be blocked for a long time. Although dynamic data aggregation reduces the probability of bus collisions, high-priority and low-priority tasks are mixed in a transmission queue, which cannot guarantee the real-time performance of high-priority tasks.

[0042] To address the aforementioned technical problems, embodiments of this application provide a control method, system, electronic device, and computer-readable storage medium for a task data queue. This control method utilizes a circular queue of multiple buffers to achieve a cyclical flow of processing states between filling, sending, and ready states. Specifically, after one buffer is filled, data is sent, the next buffer begins filling, and other buffers remain in a ready state, achieving dynamic filling. Simultaneously, each buffer is configured with storage space of different priorities, allowing for the storage of task data of varying priorities. A single buffer can include aggregated task data of multiple priorities. Therefore, this task data queue control method reduces the number of transmissions, improves buffer utilization and memory usage, suppresses bus conflicts, and enhances real-time performance through dynamic filling and data aggregation, thereby improving the real-time performance and reliability of data transmission.

[0043] It should be noted that the control method for the task data queue provided in this application embodiment uses SPI communication as an example for illustration, and does not imply that the application environment of the control method for the task data queue is limited. For example, it can be applied to I2C (Inter-Integrated Circuit), UART (Universal Asynchronous Receiver / Transmitter), etc., which will not be elaborated on below.

[0044] Please see Figure 1 , Figure 1 The following is a flowchart illustrating a method for controlling a task data queue, as provided in an embodiment of this application. The method includes the following steps: S100: Initialize a circular queue of multiple buffers, including a first task data area and a second task data area; S200: Perform a circular queue traversal based on multiple buffers, and process the current buffer encountered during the traversal as follows: S210: Obtain at least one task data to be sent; S220: Determine the priority type of the task data to be sent; S230: Store the task data to be sent into the first task data range or the second task data range according to the priority type of the task data to be sent; S240: Send the task data in the current buffer; S250: Switch to the next buffer in the circular queue.

[0045] For example, a circular queue of multiple buffers is initialized, wherein the number of buffers is N, N≥2; in this embodiment of the application, each buffer can be divided into three states: filled, transferred, and ready, and the state cycle of each buffer is: ready → filled → transferred → ready; Each buffer is processed cyclically according to the circular queue. That is, when the current buffer is in the filled state, it changes to the transmission state and data is transmitted after the current buffer is filled. The next buffer is in the ready state. After the current buffer is filled and changes to the transmission state, the next buffer changes from the ready state to the filled state. The remaining buffers are in the ready state and waiting.

[0046] For example, under high load conditions, the multiple buffers provided in this application embodiment can simultaneously achieve "one buffer in the transmission state, the next buffer in the filling state, and the next buffer in the ready state", completing data filling and data separation in time, and realizing efficient utilization of multiple buffers.

[0047] Optionally, after the data transfer in the buffer is complete, the buffer can be inserted into the tail of the circular queue, thereby forming a closed loop of the circular queue; In some implementations, under low load conditions, after the buffer has finished transmitting data, it can also be inserted at the head of the circular queue. That is, only one buffer is needed to complete the "ready → fill → transmit → ready" transmission cycle, while other buffers are in a ready state. Thus, more options are provided for the use of buffers under low load conditions.

[0048] For example, each buffer includes a first task data range and a second task data range. During the process of filling the task data to be sent into the buffer, the task data is filled into different task data ranges in the buffer according to the different priority types of the task data to be sent. Thus, the task data is filled into different task data ranges in the buffer by the insertion priority of the task data itself, so as to avoid the mixing of tasks from different rounds in the queue in one buffer, thereby avoiding the situation where low-priority tasks are processed before high-priority tasks due to the priority confusion of task data.

[0049] For example, after the current buffer is filled with task data, during the process of sending task data, task data can be sent sequentially according to the preset order of the first task data range and the second task data range.

[0050] For example, multiple task data can be stored in a single buffer, wherein the first task data range and the second task data range can each store different task data, effectively improving buffer utilization and reducing memory usage.

[0051] In some implementations, each buffer may also include more task data ranges, such as a third task data range, a fourth task data range, etc. Optionally, the number of task data intervals in the buffer corresponds to the number of priority types of task data, and task data of different priority types are filled into the corresponding task data intervals in the buffer.

[0052] In some implementations, when the number of task data intervals is three or more, according to the task data queue control method provided in this application, the first task data interval and the second task data interval can be processed equally: task data of different priority types are filled into the corresponding task data intervals of the buffer respectively, and when the buffer sends data, the task data is transmitted sequentially according to the order of each task data interval.

[0053] The task data queue control method provided in this application embodiment realizes a cyclical process of processing multiple buffers between filling, sending, and ready states through a circular queue of multiple buffers. That is, after one buffer is filled, data is sent, the next buffer begins to be filled, and other buffers are in a ready state, realizing dynamic filling. At the same time, each buffer is configured with storage space of different priorities, which can store task data of different priorities respectively. A buffer can include aggregated task data of multiple priorities. Thus, the task data queue control method reduces the number of transmissions, improves buffer utilization and reduces memory occupation, suppresses bus conflicts, and enhances real-time performance through dynamic filling and data aggregation, thereby achieving the technical effect of improving the real-time performance and reliability of data transmission.

[0054] Please see Figure 2 , Figure 2 This is a flowchart illustrating another method for controlling a task data queue provided in an embodiment of this application.

[0055] In some implementations, the priority type includes a first priority and a second priority, and the first priority is greater than the second priority. S230: The step of storing the task data to be sent into a first task data range or a second task data range according to the priority type includes: S231: If the priority type of the task data to be sent is first priority, store the task data to be sent in the first task data range; S232: If the priority type of the task data to be sent is the second priority, store the task data to be sent in the second task data range.

[0056] For example, in the priority type of task data, the first priority is high priority and the second priority is low priority. When filling data, the data is filled into the corresponding task data interval according to the priority. Thus, the task data is filled into the corresponding task data interval by the insertion priority of the task data itself. Each task data interval contains task data of the same priority, avoiding priority confusion caused by tasks of different priorities being mixed in the sending queue of a buffer.

[0057] In some implementations, S232: the step of storing the task data to be sent into the first task data range includes: Get the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the first task data range in sequence according to the storage order.

[0058] For example, within the first task data interval, all stored task data are of the same priority. At this time, the task data to be sent is arranged according to the arrival time information and sequentially filled into the first task data interval to avoid chaotic filling of task data.

[0059] In some implementations, S232: the step of storing the task data to be sent into the second task data range includes: Get the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the second task data range in sequence according to the storage order.

[0060] For example, within the second task data interval, all stored task data are of the same priority. At this time, the task data to be sent is arranged according to the arrival time information and sequentially filled into the second task data interval to avoid chaotic filling of task data.

[0061] In some implementations, the first task data range and the second task data range are configured sequentially along the data reading direction. S240: The step of sending the task data of the current buffer includes: S241: Send the task data within the first task data range in the current buffer; S242: After the task data in the first task data range is sent, the task data in the second task data range is sent.

[0062] For example, during the process of sending data in the buffer, the sending order is from the first task data area to the second task data area, ensuring that high-priority task data is processed before low-priority task data, thus avoiding the problem that high-priority tasks may be blocked by low-priority tasks for a long time.

[0063] In some implementations, before step S240: sending the task data in the current buffer, the method further includes: S233: Get the remaining space in the current buffer; S234: Determine whether the data capacity of the remaining space is greater than or equal to the data length of the task data to be sent; If so: then return to S210: obtain at least one task data to be sent; If not, proceed to the next S240: send the task data in the current buffer.

[0064] For example, when the current buffer is not completely filled and there is still space to receive new task data, the buffer can continue to receive new task data to be sent, ensuring the utilization rate of the buffer and effectively solving the problems of low buffer utilization and high memory consumption in traditional single-buffer designs. In some embodiments, before the step of sending the task data in the current buffer in S240, the method further includes: S235: Get the current dwell time of the buffer; S236: Determine whether the current dwell time in the buffer is greater than or equal to a preset time threshold; If not, return to step S235: obtain the current dwell time of the buffer; If so, then execute step S240: Send the task data in the current buffer.

[0065] For example, if the buffer is not filled and there is still space remaining, but the dwell time exceeds a preset time threshold, the transmission is forcibly triggered to send the task data of the current buffer in order to avoid the accumulation of delays.

[0066] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating the process of sending task data in the current buffer, as provided in an embodiment of this application.

[0067] In some implementations, S240: the step of sending task data in the current buffer includes: S2401: Obtain the status information of the transmission interface; S2402: Determine whether the status information of the transmission interface is idle; If not, return to S2401: Obtain the status information of the transmission interface; If so, then S2403: Submit the task data in the current buffer to the transmission interface; S2404: Send the task data of the current buffer through the transmission interface.

[0068] For example, by querying the status information of the transmission interface, after confirming that the transmission interface is in an idle state, the task data in the current buffer is submitted for transmission, and then switched to the next idle buffer for filling, ensuring the thread safety of state switching, avoiding data overwriting, and improving reliability and stability.

[0069] For example, atomic operations ensure thread safety during state transitions and prevent data overwriting. In SPI communication, an atomic operation means that a complete SPI transaction (e.g., writing a command to a slave device and reading its response) can be executed without being interrupted by other higher-priority tasks, interrupts, or threads. The transaction either executes completely or not at all, with no intermediate states visible.

[0070] In some implementations, after step S240: sending the task data in the current buffer, the method further includes: S243: Obtain the data transmission result; S244: If the data transmission fails, retain the task data in the current buffer, place the current buffer at the end of the circular queue, or insert the current buffer after the next buffer.

[0071] For example, when task data transmission fails, the redundant design of multiple buffers supports retrying of transmission failures, which can effectively reduce the data packet loss rate and effectively solve the problems of data packet loss and poor fault tolerance after the traditional single buffer design is exhausted.

[0072] In some implementation scenarios, combined with Figures 1 to 3 The task data queue control method shown can overcome the shortcomings of existing technologies, such as low buffer utilization, high memory consumption, high probability of bus conflicts, poor real-time performance, poor fault tolerance, and inability to dynamically adjust the buffer usage order according to task priority. A specific implementation example is shown below: Step 1: Construct a circular queue containing N buffers, where N≥2, and the capacity of each buffer includes the data range of the first task and the data range of the second task. Optionally, the capacity of the first task data interval is the maximum length of high-priority periodic task data, and the capacity of the second task data interval is the maximum length of low-priority periodic task data, supporting multiple buffers to alternately fill and transmit. The capacity of the first task data range and the capacity of the second task data range can also be limited according to actual needs. This is only an example and not a limitation. For example, the period of high-priority periodic task data can be 10ms, and the period of low-priority periodic task data can be 20ms; or, the period of high-priority periodic task data can be 5~15ms, and the period of low-priority periodic task data can be 15~25ms.

[0073] Step 2: When the application layer calls the SPI interface, task data A or task data B is dynamically appended to the task data range corresponding to the current active buffer in the order of arrival. Task data A is high-priority task data, and task data B is low-priority task data. It allows a single buffer to store data from multiple tasks, such as combinations like A+A, A+B, and B+A. Step 3: Calculate the remaining space of the current buffer in real time, and determine whether the length of the newly received task data exceeds the remaining space of the current active buffer. If yes, proceed to step 4; otherwise, return to step 2. Step 4: Query the SPI transmission status. Once it is confirmed to be idle, asynchronously submit the task data in the current buffer and switch to the next idle buffer.

[0074] Step 1 includes: Step 101: Initialize N buffers and maintain the three states of each buffer: filled, transferred, and ready. Step 102: Avoid priority confusion caused by mixing tasks from different rounds in the same queue by adjusting the insertion priority of the tasks themselves; Step 103: The internal task priority is promoted by moving the task write pointer (high-priority tasks that arrive later in the same buffer can be directly inserted before low-priority tasks), and the task is processed strictly in priority order by using the read pointer. The transfer in one buffer is completed before the transfer in the next buffer is processed, so as to avoid low-priority tasks being starved by high-priority tasks. For example, each buffer is internally divided into a contiguous high-priority region (first task data area) and a low-priority region (second task data area); each buffer maintains two write pointers: a high-priority write pointer (initially pointing to the start address of the buffer) and a low-priority write pointer (initially pointing to the area between the first task data area and the second task data area); When high-priority task data arrives, it is appended to the high-priority area, and the high-priority write pointer moves forward accordingly. When low-priority task data arrives, it is appended to the low-priority area, and the low-priority write pointer moves forward accordingly. In this way, it is ensured that high-priority task data is always stored at the beginning of the buffer (high-priority area), while low-priority task data is stored at the end (low-priority area). The read pointer always starts reading data from the beginning address of the buffer. Therefore, data in the high-priority area is transmitted first, and data in the low-priority area is transmitted later, ensuring that tasks are processed strictly in priority order.

[0075] Step 4 includes: Step 401: If the buffer is not full but the dwell time exceeds the preset threshold, such as 1.5 times the cycle of task B, then the transmission is forcibly triggered to avoid the accumulation of delay. Step 402: Ensure thread safety of state transitions through atomic operations to avoid data overwriting; Step 403: The multi-buffer redundancy design supports retrying in case of transmission failure, reducing the data packet loss rate.

[0076] For example, the task data queue control method provided in this application embodiment is a task queue management method with dynamic filling and intelligent triggering, which has at least the following beneficial effects: 1. Improved buffer utilization and reduced memory usage; by dynamically filling aggregated multi-task data, the buffer utilization rate was increased from fixed single storage (task A or task B) to over 96% (such as storing various combinations of task A and task B), and memory usage was reduced by 50%~80%, effectively solving the problems of low buffer utilization and high memory usage in traditional single buffer design. 2. It suppresses bus conflicts and enhances real-time performance; data aggregation reduces the number of SPI transmissions, and the conflict probability of 10ms / 20ms periodic tasks drops from the theoretical peak of 50% to below 10%. The forced submission strategy based on the timeout mechanism ensures that the maximum transmission delay of high-priority tasks (such as A) is ≤15ms (the original scheme can reach 100ms without constraints), effectively solving the problems of high bus conflict probability and poor real-time performance in traditional schemes. 3. Improved fault tolerance; the multi-buffer redundancy design supports retrying after transmission failure, with a data packet loss rate of less than 0.1% (the original solution had a packet loss rate of ≥5% due to buffer exhaustion), effectively solving the problems of data packet loss and poor fault tolerance after buffer exhaustion in the traditional single-buffer design; 4. Improved system reliability and stability: Maintained three states for each buffer: filled, transferred, and ready. Atomic operations ensured thread safety during state transitions, preventing data overwriting and improving system reliability and stability.

[0077] Please see Figure 4 , Figure 4 This is a structural block diagram of a control system for a task data queue provided in an embodiment of this application. The control system for the task data queue includes: Initialization module 100 is used to initialize a circular queue of multiple buffers, including a first task data area and a second task data area; The processing module 200 is used to traverse the circular queue according to multiple buffers and perform the following processing on the current buffer being traversed: obtain at least one task data to be sent; determine the priority type of the task data to be sent; store the task data to be sent into the first task data range or the second task data range according to the priority type of the task data to be sent; send the task data in the current buffer; and switch to the next buffer in the circular queue.

[0078] In some implementations, the priority type includes a first priority and a second priority, and the first priority is greater than the second priority. The processing module 200 is further configured to: if the priority type of the task data to be sent is the first priority, store the task data to be sent in the first task data range; if the priority type of the task data to be sent is the second priority, store the task data to be sent in the second task data range.

[0079] In some implementations, the processing module 200 is further configured to: obtain arrival time information of the task data to be sent; determine the storage order based on the arrival time information; and store the task data to be sent into the first task data range in sequence according to the storage order.

[0080] In some implementations, the processing module 200 is further configured to: obtain arrival time information of the task data to be sent; determine the storage order based on the arrival time information; and store the task data to be sent into the second task data range in sequence according to the storage order.

[0081] In some implementations, the first task data interval and the second task data interval are configured sequentially along the data reading direction, and the processing module 200 is further configured to: send task data in the first task data interval in the current buffer; and after the task data in the first task data interval is sent, send task data in the second task data interval.

[0082] In some implementations, the processing module 200 is further configured to: obtain the remaining space of the current buffer; if the data capacity of the remaining space is greater than or equal to the data length of the task data to be sent, then return to the step of obtaining at least one task data to be sent.

[0083] In some implementations, the processing module 200 is further configured to: obtain the dwell time of the current buffer; if the dwell time of the current buffer is greater than or equal to a preset time threshold, then execute the step of sending the task data of the current buffer.

[0084] In some implementations, the processing module 200 is further configured to: obtain the status information of the transmission interface; if the status information of the transmission interface is idle, submit the task data of the current buffer to the transmission interface; and send the task data of the current buffer through the transmission interface.

[0085] In some implementations, the processing module 200 is also used to: obtain the data transmission result; if the data transmission result fails, retain the task data in the current buffer, place the current buffer at the end of the circular queue, or insert the current buffer after the next buffer.

[0086] It should be noted that the control system for the task data queue provided in this application embodiment is related to... Figures 1 to 3 The method embodiments shown correspond to each other, and will not be described again here to avoid repetition.

[0087] This application also provides an electronic device, please refer to [link to application]. Figure 5 , Figure 5This is a structural block diagram of an electronic device provided in an embodiment of this application. The electronic device may include a processor 510, a communication interface 520, a memory 530, and at least one communication bus 540. The communication bus 540 is used to enable direct communication between these components. In this embodiment, the communication interface 520 of the electronic device is used for signaling or data communication with other node devices. The processor 510 may be an integrated circuit chip with signal processing capabilities.

[0088] The processor 510 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor, or the processor 510 can be any conventional processor.

[0089] The memory 530 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc. The memory 530 stores computer-readable instructions. When these computer-readable instructions are executed by the processor 510, the electronic device can perform the aforementioned operations. Figures 1 to 3 The various steps involved in the method implementation examples.

[0090] Alternatively, the electronic device may also include a storage controller and an input / output unit.

[0091] The memory 530, storage controller, processor 510, peripheral interface, and input / output unit are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 540. The processor 510 is used to execute executable modules stored in the memory 530, such as software function modules or computer programs included in electronic devices.

[0092] The input / output unit is used to provide users with the ability to create tasks and to set optional start periods or preset execution times for those tasks, thereby enabling user-server interaction. The input / output unit may be, but is not limited to, a mouse and keyboard.

[0093] Understandable. Figure 5 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 5 The more or fewer components shown, or having the same Figure 5 The different configurations shown. Figure 5 The components shown can be implemented using hardware, software, or a combination thereof.

[0094] This application also provides a storage medium storing instructions. When the instructions are run on a computer, the computer program is executed by a processor to implement the method described in the method embodiment. To avoid repetition, the method will not be described again here.

[0095] This application also provides a computer program product that, when run on a computer, causes the computer to perform the method described in the method embodiment.

[0096] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0097] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0098] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0099] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0100] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0101] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A control method for a task data queue, characterized in that, include: Initialize a circular queue of multiple buffers, wherein the buffers include a first task data range and a second task data range; The multiple buffers are traversed in a circular queue, and the current buffer encountered during the traversal is processed as follows: Acquire at least one task data to be sent; Determine the priority type of the task data to be sent; The task data to be sent is stored in the first task data range or the second task data range according to the priority type of the task data to be sent. Send the task data in the current buffer; Switch to the next buffer in the circular queue.

2. The control method for the task data queue according to claim 1, characterized in that, The priority type includes a first priority and a second priority, and the first priority is greater than the second priority. The step of storing the task data to be sent into the first task data range or the second task data range according to the priority type includes: If the priority type of the task data to be sent is the first priority, the task data to be sent is stored in the first task data range; If the priority type of the task data to be sent is the second priority, the task data to be sent is stored in the second task data range.

3. The control method for the task data queue according to claim 2, characterized in that, The step of storing the task data to be sent into the first task data range includes: Obtain the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the first task data range in sequence according to the storage order.

4. The control method for the task data queue according to claim 2, characterized in that, The step of storing the task data to be sent into the second task data range includes: Obtain the arrival time information of the task data to be sent; The storage order is determined based on the arrival time information, and the task data to be sent is stored in the second task data range in sequence according to the storage order.

5. The control method for the task data queue according to claim 2, characterized in that, The first task data range and the second task data range are configured sequentially along the data reading direction. The step of sending the task data in the current buffer includes: Send the task data within the first task data range in the current buffer; After the task data within the first task data range is sent, the task data within the second task data range is sent.

6. The control method for the task data queue according to claim 1 or 5, characterized in that, Before the step of sending the task data in the current buffer, the method further includes: Obtain the remaining space in the current buffer; If the data capacity of the remaining space is greater than or equal to the data length of the task data to be sent, then return to the step of obtaining at least one task data to be sent.

7. The control method for the task data queue according to claim 1 or 5, characterized in that, Before the step of sending the task data in the current buffer, the method further includes: Obtain the dwell time of the current buffer; If the dwell time of the current buffer is greater than or equal to a preset time threshold, then the step of sending the task data of the current buffer is executed.

8. The control method for the task data queue according to claim 1, characterized in that, The step of sending the task data in the current buffer includes: Obtain the status information of the transmission interface; If the status information of the transmission interface is idle, then the task data of the current buffer is submitted to the transmission interface; The task data of the current buffer is sent through the transmission interface.

9. The control method for the task data queue according to claim 1, characterized in that, After the step of sending the task data in the current buffer, the method further includes: Obtain the data transmission result; If the data transmission fails, the task data in the current buffer is retained, and the current buffer is either placed at the end of the circular queue or inserted after the next buffer.

10. A control system for a task data queue, characterized in that, include: An initialization module is used to initialize a circular queue of multiple buffers, wherein the buffers include a first task data range and a second task data range; The processing module is configured to perform a circular queue traversal based on the plurality of buffers, and perform the following processing on the current buffer being traversed: obtain at least one task data to be sent; determine the priority type of the task data to be sent; and store the task data to be sent into the first task data range or the second task data range according to the priority type of the task data to be sent. Send the task data in the current buffer; switch to the next buffer in the circular queue.

11. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the control method for a task data queue as described in any one of claims 1 to 9.

12. A computer storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the task data queue control method as described in any one of claims 1 to 9.