Data processing method, device, equipment and storage medium
By storing data descriptors in the SPI interface to the queue corresponding to their priority and processing them according to priority, the problem that high-priority data in the SPI interface cannot be transmitted first is solved, and data processing efficiency and applicability are improved.
Patent Information
- Application Number
- CN202011080338.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-10
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2040-10-10
AI Technical Summary
When processing data with priority, existing SPI interfaces cannot ensure priority transmission of high-priority data, resulting in low data processing efficiency and prone to timeout problems.
By storing the data descriptors into the queue corresponding to their priority in at least two descriptor queues and processing based on the queue priority, it is ensured that high priority data is processed first.
Improve data processing efficiency, prevent data from interfering with each other, reduce processing time, and have high applicability.
Smart Images

Figure CN114327806B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to computer technology, and in particular to a data processing method, apparatus, device and storage medium. Background Art
[0002] With the development of the Internet of Things and chip design technology, the Serial Peripheral Interface (SPI) interface is widely used in functional chips, and the types and quantities of data transmitted and processed based on the SPI interface are also increasing.
[0003] In existing technology, the SPI interface relies solely on mutual exclusion locks to prevent data processing conflicts. Furthermore, when data has priority, high-priority data cannot be transmitted and processed first, requiring all data to be queued. This queuing mechanism and the use of mutual exclusion locks significantly impact the relationship between priorities, leading to long data transmission and processing wait times, causing timeouts in related software and device functions, and inefficient data processing.
[0004] Therefore, how to improve data processing efficiency has become an urgent problem that needs to be solved. Summary of the Invention
[0005] The embodiments of the present application provide a data processing method, apparatus, device, and storage medium, which can improve data processing efficiency and have high applicability.
[0006] In a first aspect, an embodiment of the present application provides a method for data processing, the method comprising:
[0007] Obtaining the data priority and data descriptor of the data to be processed;
[0008] storing the data descriptors in corresponding queues according to the data priority, the corresponding queues being queues in at least two descriptor queues whose queue priorities correspond to the data priority, the queue priorities corresponding to the descriptor queues being different;
[0009] Based on the queue priorities of the descriptor queues, the to-be-processed data corresponding to the data descriptors in the descriptor queues are processed.
[0010] In a second aspect, an embodiment of the present application provides a data processing device, the device comprising:
[0011] A descriptor acquisition module is used to obtain the data priority and data descriptor of the data to be processed;
[0012] a descriptor storage module, configured to store the data descriptors in corresponding queues according to the data priority, wherein the corresponding queues are queues in at least two descriptor queues whose queue priorities correspond to the data priority, and the queue priorities corresponding to the descriptor queues are different;
[0013] The data processing module processes the to-be-processed data corresponding to the data descriptors in each of the descriptor queues based on the queue priorities of the descriptor queues.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, wherein the processor and the memory are connected to each other;
[0015] The memory is used to store computer programs;
[0016] The processor is configured to execute the method provided in the first aspect when calling the computer program.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method provided in the first aspect above.
[0018] In an embodiment of the present application, by storing data descriptors in at least two descriptor queues whose queue priorities correspond to the data priorities corresponding to the data descriptors, each descriptor queue can contain a data descriptor corresponding to a data priority, and different descriptor queues correspond to different data priorities. Furthermore, through the queue priorities corresponding to each descriptor queue, the data to be processed can be processed according to the data priority, which can improve the data processing efficiency. Furthermore, based on the data descriptors in each descriptor queue, the corresponding data to be processed is processed, so that each data to be processed is independent of each other, preventing mutual interference between each data to be processed, and thus avoiding the problem of data priority changes caused by the mutual exclusion of processes corresponding to each data to be processed, which can further reduce the data processing time and has high applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 Schematic diagram of the data processing method provided in the embodiment of the present application;
[0021] Figure 2 It is a structural diagram of the data processing method provided in an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of a scenario for storing data descriptors provided in an embodiment of the present application;
[0023] Figure 4 This is a schematic diagram of the SPI function startup provided in an embodiment of the present application;
[0024] Figure 5 Schematic diagram of a data processing method based on queue priority according to an embodiment of the present application;
[0025] Figure 6 This is a schematic diagram of adjusting queue priorities provided in an embodiment of the present application;
[0026] Figure 7 This is a schematic diagram of the descriptor state provided by an embodiment of the present application;
[0027] Figure 8 is a structural diagram of a data processing device provided in an embodiment of the present application;
[0028] Figure 9 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0030] The embodiments of the present application can be applied to devices, equipment, processors, and chips with a serial peripheral interface (SPI), such as single-chip microcomputers and advanced reduced instruction set processors (AMR) chips. The specific application scenario requirements can be determined and are not limited here. Based on the data processing method provided in the embodiments of the present application, SPI data can be transmitted and processed between devices.
[0031] See also Figure 1 , Figure 1 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 1 As shown, the data processing method provided in the embodiment of the present application may include the following steps:
[0032] Step S1: Obtain the data priority and data descriptor of the data to be processed.
[0033] In some feasible implementations, the data to be processed in the embodiments of the present application is SPI data that has not been transmitted or processed, including but not limited to control information, calculation data, status data, log data, etc., and can be specifically determined based on the device that generates the SPI data, and is not limited here. When it is necessary to process the data to be processed, the data priority and data descriptor of the data to be processed can be obtained first.
[0034] Among them, the data descriptor of the data to be processed can be used to indicate information such as the acquisition address, transmission address, data attributes of the data to be processed, and data length of the data to be processed. The specific information can be determined based on the actual application scenario requirements and is not limited here.
[0035] Among them, the data priority of the data to be processed can be determined based on the preset data priority, such as pre-setting the data priority of control data, log data and other data related to device A to be higher than the control data, log data and other data related to device B.
[0036] Optionally, the data priority of the data to be processed can be determined based on the data type and importance of the data to be processed, and can be determined based on the actual application scenario, without limitation here. For example, if there are three types of data to be processed, namely control data, status data, and log data, in the device control scenario, the data priority of the control data is higher than the data priority of the status data, and the data priority of the status data is higher than the data priority of the log data.
[0037] Optionally, when the data descriptor of the data to be processed carries the data priority of the data to be processed, the data priority of the corresponding data to be processed can be directly determined based on the data descriptor.
[0038] Optionally, when the data descriptor of the data to be processed carries information such as the data type and data importance of the data to be processed, the data priority of the data to be processed may be determined based on the above information carried in the data descriptor.
[0039] It should be noted that the specific method of determining the data priority of the data to be processed can be determined based on the actual application scenario requirements and is not limited here.
[0040] Step S2: store the data descriptor into the corresponding queue according to the data priority.
[0041] In some feasible implementations, after the data priority and data descriptor of the data to be processed are obtained, the data descriptor may be stored in a corresponding queue.
[0042] Specifically, when storing any data descriptor in a descriptor queue, the data descriptor may be stored in the corresponding descriptor queue based on the corresponding relationship between the data descriptor and the data priority of the data to be processed corresponding to the data descriptor, as well as the corresponding relationship between each data priority and each descriptor queue. That is, based on the data priority of the data to be processed corresponding to the data descriptor, the corresponding descriptor queue is determined, and then the data descriptor is stored in the corresponding descriptor queue.
[0043] It should be noted that the correspondence between each data priority and each descriptor queue is the correspondence between each data priority and the initial queue priority of each descriptor queue. The queue priority of each descriptor queue corresponds to a data priority, and the data priorities corresponding to each descriptor queue are different. In other words, even if the queue priorities of each descriptor queue are temporarily adjusted due to data processing needs during the data processing process, during the period from the temporary adjustment to the restoration of the queue priorities, if a new data descriptor needs to be stored in the corresponding queue, the initial queue priority corresponding to the data priority of the to-be-processed data corresponding to the new data descriptor can be determined, and the new descriptor can be stored in the descriptor queue corresponding to the initial queue priority.
[0044] Among them, the creation of each descriptor queue can be created after obtaining the data priority of the data to be processed, or it can be created before obtaining the data priority of the data to be processed. The specific creation can be determined based on the actual application scenario requirements and is not limited here. For example, in the current data processing environment, the data to be processed corresponds to 3 data priorities. After obtaining the data priority of the data to be processed, descriptor queues corresponding to the 3 queue priorities of each data priority can be created based on the data priority of the data to be processed. Alternatively, multiple descriptor queues can be created in advance, each descriptor queue corresponding to a different queue priority, and then after obtaining the data priority of the data to be processed, the data descriptors can be stored in the corresponding queues according to the data priority.
[0045] Step S3: based on the queue priority of each descriptor queue, process the to-be-processed data corresponding to the data descriptors in each descriptor queue.
[0046] In some feasible implementations, when processing the pending data corresponding to the data descriptors in each descriptor queue, the pending data corresponding to the data descriptors in each descriptor queue can be processed in descending order of queue priority.
[0047] For example, assuming there are three descriptor queues with different queue priorities (high, medium, and low), the pending data corresponding to the data descriptors in the high-priority descriptor queue can be processed first. After the pending data corresponding to the data descriptors in the high-priority descriptor queue is processed or a certain preset condition is met, the pending data corresponding to the data descriptors in the medium-priority descriptor queue can be processed. This process continues in this order until the pending data corresponding to the data descriptors in the low-priority descriptor queue is processed or a certain condition is met. At this point, the pending data corresponding to the data descriptors in each descriptor queue are processed again in descending order of queue priority.
[0048] In some feasible implementations, the storage process of the data descriptor in the above step S2 can be found in Figure 2 , Figure 2 This is a schematic diagram of the structure of the data processing method provided in the embodiment of the present application. Figure 2 As shown, process X is responsible for the relevant functions of device 1, so the data to be processed (such as control data and status data) corresponding to device 1 can be obtained based on process X. Process Y is responsible for the relevant functions of device 2, so the data to be processed (such as control data and status data) corresponding to device 2 can be obtained based on process Y. Assuming that the data priority of control data is higher than the data priority of status data, and the queue priority of descriptor queue 1 is higher than the queue priority of descriptor queue 2, the data descriptors of the status data and control data corresponding to process X can be obtained at this time, and the data descriptor of the status data can be stored in descriptor queue 2, and the data descriptor of the control data can be stored in descriptor queue 1. Similarly, the data descriptors of the status data and control data corresponding to process Y can be obtained, and the data descriptor of the status data can be stored in descriptor queue 2, and the data descriptor of the control data can be stored in descriptor queue 1.
[0049] Devices 1 and 2 share a common SPI interface, allowing process R to process pending data corresponding to the data descriptors in each descriptor queue. Process R can perform data processing based on its own SPI interface functions. After obtaining their corresponding data descriptors, processes X and Y can continue their respective tasks without waiting for the pending data to be transmitted and processed, improving data processing efficiency.
[0050] Furthermore, for data descriptors corresponding to the same data priority, they can be stored in the corresponding descriptor queue in sequence according to the acquisition time of each data descriptor, and the descriptor state of each data descriptor in the descriptor queue can be determined as an executable state to indicate that the pending data corresponding to the data descriptor has not been processed.
[0051] See also Figure 3 , Figure 3 This is a schematic diagram of a scenario for storing data descriptors provided in an embodiment of the present application. Figure 3 The figure shows a descriptor queue, where Obj1, Obj2, and Obj3 are the data descriptors in the descriptor queue, and the order in which Obj1, Obj2, and Obj3 are acquired is the same as the order in which they are arranged in the descriptor queue. Before the new data descriptor Obj_Y enters the descriptor queue, the location pointed to by the Prod_head pointer indicates that the new data descriptor is about to enter the descriptor queue. After the data descriptor Obj_Y enters the descriptor queue, the Prod_tail pointer points to the data descriptor Obj_Y, indicating that the data descriptor Obj_Y at that location has entered the descriptor queue. The location pointed to by the Cons_head pointer is the location of the data descriptor corresponding to the last pending data processed by the descriptor queue.
[0052] When two data descriptors Obj_X and Obj_Y with the same acquisition time enter the descriptor queue at the same time, the order of entering the descriptor queue can be determined based on the comparison and exchange instructions. For example, if the data descriptor Obj_Y successfully enters the 4th position of the descriptor queue, the Prod_head pointer points to the 5th position, indicating that the data descriptor Obj_X is about to enter the 5th position of the descriptor queue. After the data descriptor Obj_X enters the 5th position of the descriptor queue, the Prod_head points to the 6th position. For the data descriptor Obj_Y, since it has just entered the descriptor queue, its corresponding pending data has not been processed. Therefore, the descriptor status (Obj_status[4]) of the data descriptor Obj_Y in the descriptor queue can be determined as the executable state (cmd_ok) to indicate that the pending data corresponding to the data descriptor has not been processed.
[0053] In some feasible implementations, the specific process of processing the to-be-processed data corresponding to the data descriptors in each descriptor queue in the above step S3 can be executed by a processor, and can be specifically implemented by a specific process in the processor, which is not limited here.
[0054] Specifically, the processor can detect the current state of the processor at preset time intervals. If the current state is active and there are no data descriptors for unprocessed data in each descriptor queue, the processor is controlled to enter a dormant state to reduce resource consumption. In other words, when there are no data descriptors for new data to be processed in each descriptor queue, the processor is controlled to enter a dormant state from an active state.
[0055] If the current state is the sleep state and there are data descriptors for unprocessed data in each of the descriptor queues, the processor is activated to process the corresponding pending data based on the data descriptors in each of the descriptor queues. In other words, when the processor is in the sleep state, if it detects that a new data descriptor has entered any of the descriptor queues, it can enter the active state from the sleep state to begin processing the pending data corresponding to the new data descriptor.
[0056] After the processor completes processing the corresponding data to be processed based on the data descriptors in each descriptor queue, it may enter the dormant state from the active state.
[0057] Specifically, the processor can implement data processing based on the SPI interface function within a specific process. Figure 4 , Figure 4 This is a schematic diagram of the SPI function startup provided by the embodiment of the present application. Figure 4 In the SPI interface, upon detecting that the data descriptor corresponding to the pending data of process X or process Y has entered the descriptor queue, the processor can read the status of the SPI interface function, which can be regarded as the current state of the processor. When a new data descriptor enters any descriptor queue, the processor can read the status of the SPI interface function. If the status of the SPI interface function is active, the SPI interface function can be activated to process the pending data corresponding to the new data descriptor.
[0058] When the state of the SPI interface function is the dormant state, the SPI interface function can be activated from the dormant state based on the start instruction, and then the corresponding to-be-processed data of the new data descriptor is processed, and the dormant state is entered again after the processing is completed.
[0059] Furthermore, the processor can periodically poll the SPI interface function status based on process Z, that is, check the SPI interface function status at preset time intervals. When a new data descriptor enters the descriptor queue, the SPI interface function can be ensured to be in an active state, thereby ensuring the timely processing of the pending data. Polling also ensures that all pending data can be processed, and avoids the processor CPU being occupied by the infinite loop operation.
[0060] In some feasible implementations, during the process of processing the pending data based on the queue priorities of the descriptor queues in step S3, new data descriptors may continuously appear in each descriptor queue. When the pending data corresponding to the data descriptors in each descriptor queue are processed sequentially according to the queue priorities, if new data descriptors are continuously stored in a descriptor queue with a high queue priority, the pending data corresponding to the data descriptors in the descriptor queue with the high queue priority may be processed for a long time, resulting in the problem that the pending data corresponding to the data descriptors in the descriptor queue with a low queue priority are not processed in a timely manner.
[0061] Based on this, in the process of processing the pending data corresponding to the data descriptors in each descriptor queue in order from high to low based on the queue priority of each descriptor queue, when processing the pending data corresponding to the data descriptors in any descriptor queue, if the processed data in the descriptor queue (for the convenience of description, hereinafter referred to as the first data) meets the preset condition (for the convenience of description, hereinafter referred to as the first preset condition), or the processing of the pending data corresponding to the data descriptor in the descriptor queue is completed, then stop processing the pending data corresponding to the remaining data descriptors in the descriptor queue.
[0062] For each descriptor queue, the first preset condition is any one of the following: the amount of the first data exceeds a first data amount threshold, the number of the first data exceeds a first number threshold, or the processing time of the first data exceeds a first time threshold. Other preset conditions may also be used, and the specific conditions may be determined based on actual application scenario requirements and are not limited here. The first data amount threshold, the first number threshold, and the first time threshold may be determined based on actual application scenarios and are not limited here.
[0063] That is, when processing the pending data corresponding to the data descriptors in each descriptor queue, the processing of the pending data corresponding to the descriptor queue is stopped after a certain amount of data is processed. Alternatively, the processing of the pending data corresponding to the descriptor queue is stopped after a certain number of data is processed. Alternatively, the processing of the pending data corresponding to the descriptor queue is stopped after a certain period of time.
[0064] Furthermore, after stopping processing of the pending data corresponding to the remaining data descriptors in the descriptor queue, processing of the pending data corresponding to the data descriptors in the other descriptor queues can be started, so that the pending data corresponding to the data descriptors in the other descriptor queues can all be processed in a timely manner. After processing of the pending data corresponding to the data descriptors in the descriptor queue with the lowest queue priority is completed, processing of the pending data corresponding to the data descriptors in the descriptor queues is resumed based on the queue priority order from high to low.
[0065] Furthermore, after stopping processing of the pending data corresponding to the above-mentioned descriptor queue, the descriptor queues whose queue priorities are lower than the queue priority of the descriptor queue and whose queue priorities are adjacent to the queue priority of the descriptor queue (hereinafter referred to as the first target descriptor queue for convenience of description) can be re-processed in descending order of queue priority. Assuming that there are three queue priorities of high, medium and low, if, based on the above implementation method, the processing of the pending data corresponding to the data descriptors in the descriptor queue with the medium queue priority is stopped, the processing of the pending data corresponding to the data descriptors in the descriptor queue with the low queue priority can be carried out.
[0066] Furthermore, when processing the pending data corresponding to the data descriptors in the descriptor queues of low queue priority, if the first data corresponding to the descriptor queues of low queue priority meets the first preset condition, the pending data corresponding to the data descriptors in each descriptor queue may be reprocessed in the order of high, medium, and low queue priorities. During the reprocessing process, whether the first data in each descriptor queue during the current processing process meets the first preset condition is re-recorded, so that the pending data corresponding to the data descriptors in each descriptor queue are processed cyclically based on the above implementation method.
[0067] Optionally, the above-mentioned first target descriptor queue can also be a descriptor queue whose queue priority is higher than the queue priority of the descriptor queue and in which unprocessed data exists in the to-be-processed data corresponding to the data descriptor. That is, after stopping processing the to-be-processed data corresponding to the above-mentioned descriptor queue, the unprocessed data corresponding to the descriptor queue whose queue priority is higher than the queue priority of the descriptor queue and in which unprocessed data exists in the to-be-processed data corresponding to the data descriptor can be re-processed. That is, after stopping processing the to-be-processed data corresponding to the data descriptor in any descriptor queue based on the above-mentioned first preset condition, the to-be-processed data corresponding to the new data descriptor in the descriptor queue with the highest priority and new data descriptors in the descriptor queue with a queue priority higher than the priority of the descriptor queue can be processed.
[0068] Moreover, in the process of processing the pending data corresponding to the new data descriptor in the descriptor queue with the highest priority and a new data descriptor, it is re-determined whether the first data in the descriptor queue during the current processing meets the first preset condition. When the first preset condition is met, the processing of the pending data corresponding to the new data descriptor in the descriptor queue is stopped, and the pending data corresponding to the data descriptors in each descriptor queue are re-processed in order from high to low based on the above-mentioned queue priority.
[0069] See also Figure 5 , Figure 5 Schematic diagram of the process of data processing based on queue priority provided by the embodiment of the present application. Figure 5 As shown, when starting to process the pending data corresponding to the data descriptors in each descriptor queue, first determine whether the data descriptors exist in the descriptor queue with a high queue priority. If so, process the pending data corresponding to the data descriptors in the descriptor queue with a high queue priority. If not, determine whether the data descriptors exist in the descriptor queue with a medium queue priority.
[0070] If there is a data descriptor in the descriptor queue of the medium queue priority, the to-be-processed data corresponding to the data descriptor in the descriptor queue of the medium queue priority is processed, and when all processing is completed or the first preset condition is met, it is re-determined whether there is a new data descriptor in the descriptor queue of the high queue priority. If there is no data descriptor in the descriptor queue of the medium queue priority, it is determined whether there is a data descriptor in the descriptor queue of the low queue priority.
[0071] If there is a data descriptor in the descriptor queue of the low queue priority, the pending data corresponding to the data descriptor in the descriptor queue of the low queue priority is processed, and when all processing is completed or the first preset condition is met, it is re-determined whether there is a new data descriptor in the descriptor queue of the high queue priority. If there is no data descriptor in the descriptor queue of the low queue priority, the processing of the pending data is stopped.
[0072] In some feasible implementations, in the process of processing the pending data corresponding to each descriptor queue based on the above-mentioned first preset condition and queue priority, for the descriptor queue with a low queue priority, the pending data corresponding to the data descriptor in the descriptor queue may still face the situation of data timeout processing. When there are many data descriptors in each descriptor queue, that is, when there are many pending data to be processed, since the above-mentioned implementation method is based on the order of queue priority from high to low, in order to further prevent the processing timeout of the pending data corresponding to the lower queue priority, in any of the above-mentioned processes of processing the pending data based on the order of queue priority from high to low, the priority of the second target descriptor queue in all descriptor queues can be adjusted based on the preset priority adjustment strategy. The pending data corresponding to the data descriptors in each of the descriptor queues are processed based on the adjusted queue priority of each descriptor queue.
[0073] The second target descriptor queue is at least one of all the descriptor queues, and the queue priority of the second target descriptor queue is lower than the queue priority of any of the other descriptor queues. For example, the descriptor queue with the lowest queue priority and the to-be-processed data corresponding to the data descriptor has not been processed or has been processed in very small part. In this case, the queue priority of the second target descriptor queue can be increased, so that when the to-be-processed data is processed in descending order based on the adjusted queue priority, the to-be-processed data corresponding to the data descriptors in the descriptor queues that originally had lower queue priorities can be processed in advance to a certain extent.
[0074] Optionally, the second target descriptor queue may be at least one of all descriptor queues, and the queue priority of the second target descriptor queue may be higher than the queue priority of any of the other descriptor queues. In this case, the queue priority of the second target descriptor queue may be lowered, so that the pending data may be processed in descending order based on the adjusted queue priorities. This may allow, to a certain extent, the pending data corresponding to the data descriptors in the descriptor queues originally having lower queue priorities to be processed in advance.
[0075] In some feasible implementations, when adjusting the queue priority of the second target descriptor queue, relevant information about the data that has been processed by all current descriptor queues may be recorded each time the data to be processed is processed in descending order based on the queue priority. When the relevant information meets a preset condition (hereinafter referred to as the third preset condition for ease of description), the priority of the second target descriptor queue is adjusted based on the relevant information.
[0076] Among them, the relevant information of the above-mentioned processed data includes but is not limited to the total data volume, total number and total processing time of the processed data, which can be determined based on the actual application scenario and is not limited here.
[0077] If the amount of all processed data to be processed reaches a third data amount threshold, or the number of all processed data to be processed reaches a third number threshold, or the processing time corresponding to all processed data to be processed reaches a third time threshold, the queue priority of the second target descriptor queue is adjusted. After each adjustment of the queue priority of the second target descriptor queue, information related to the processed data after the queue priority adjustment is re-recorded for the next queue priority adjustment.
[0078] Furthermore, each time the queue priority is adjusted and the data to be processed is processed based on the adjusted queue priority, the data to be processed corresponding to the data descriptors in each descriptor queue may be processed again based on the queue priority.
[0079] Furthermore, when processing the pending data corresponding to the data descriptors in each descriptor queue based on the adjusted queue priorities of each descriptor queue, when the first data of the descriptor queues with the lowest queue priority before adjustment or the first preset number of descriptor queues with queue priorities from low to high (hereinafter referred to as the third target descriptor queue for convenience of description) in each descriptor queue meets a preset condition (hereinafter referred to as the second preset condition for convenience of description), the queue priority of each descriptor queue can be restored to the queue priority before adjustment, so that after the pending data corresponding to the data descriptors in the descriptor queues with lower queue priorities are processed in a timely manner, the pending data can be processed according to the normal queue priority. Wherein, the above-mentioned first data is also the data that has been processed by each descriptor queue during the processing process.
[0080] For any descriptor queue in the third target descriptor queue, the second preset condition may also be any one of the following: the amount of the first data exceeds the second data amount threshold, the number of the first data exceeds the second number threshold, or the processing time of the first data exceeds the second time threshold. Other preset conditions may be determined based on actual application scenario requirements and are not limited here. The second data amount threshold, the second number threshold, and the second time threshold may be determined based on actual application scenarios and are not limited here.
[0081] That is, after adjusting the queue priority of the second target descriptor queue, when processing the pending data corresponding to the data descriptors in the third target descriptor queue, after processing a certain amount of the pending data corresponding to the data descriptors in the third target descriptor queue, processing of the pending data corresponding to the third descriptor queue is stopped. After processing a certain number of the pending data corresponding to the data descriptors in the descriptor queue, processing of the pending data corresponding to the third descriptor queue is stopped. After processing the pending data corresponding to the data descriptors in the third target descriptor queue for a certain period of time, processing of the pending data corresponding to the descriptor queue is stopped.
[0082] In some feasible implementations, the third preset condition, the second preset condition, and the first preset condition may be the same condition or different conditions, and the selection of each preset threshold in each preset condition may be determined based on the actual application scenario, and no limitation is made here.
[0083] For example, the length of the pending data corresponding to the data descriptors in each descriptor queue is between 64 bytes and 128 bytes. Taking an SPI transmission rate of 20 Mbps as an example, the transmission time of the pending data corresponding to each data descriptor is approximately between 25.6 μs and 51.2 μs. If milliseconds are used as the time base, the transmission time of each pending data can be considered to be basically the same. Therefore, the number of processed data can be used as a preset condition to process the pending data based on the preset condition. For example, the threshold of the descriptor queue can be set to 20 pending data, that is, the pending data corresponding to a maximum of 20 descriptors can be processed. In this way, the maximum time consumed by a descriptor queue on the SPI interface is guaranteed to be within approximately 1 ms, ensuring the transmission timeliness of the pending data. If the data lengths of the pending data corresponding to each data descriptor vary significantly, the total amount of processed data can be used as a preset condition. Assuming that the data length of each pending data corresponding to each descriptor queue is between 64 bytes and 1500 bytes, the SPI transmission rate is 20Mbps, and the transmission time of each pending data is approximately between 25.6us and 600us. If ms is still used as the above preset condition, the transmission time between each pending data can differ by up to 23 times, which may result in some pending data not being processed in a timely manner.
[0084] In some feasible implementations, the queue priority of each descriptor queue before adjustment may correspond to different queue priority values, and the priority of each descriptor queue is adjusted by adjusting the queue priority value of each descriptor queue. The specific implementation method of adjusting the queue priority based on the queue priority value is not limited here.
[0085] For example, the transmission time for a 1000-bit segment of pending data is 100ms, and the SPI transmission rate is 20Mbps. If the third preset condition is the third data volume threshold (64,000 bits), that is, every time 64,000 bits of pending data are processed, the queue priority value of the descriptor queue that has not been polled is reduced once. In other words, the queue priority is adjusted every 3.2ms. For the descriptor queue with the lowest queue priority, its queue priority value can theoretically change up to 31 times. Furthermore, if the preset principle of reserving 70% of the transmission bandwidth is followed, the initial queue priority value of the descriptor queue can change up to 21 times to reach the queue priority value corresponding to the highest priority. If the queue priority value is higher, the queue priority is lower. When the queue priority value is reduced to increase the queue priority, the amount by which the queue priority value of the descriptor queue with the lowest queue priority is reduced each time must be greater than (the queue priority value of the current descriptor queue - the queue value of the highest priority queue) / 21.
[0086] Combine Figure 6 , Figure 6 This is a schematic diagram of adjusting queue priority provided by an embodiment of the present application. Figure 6 As shown, the initial queue priority value of descriptor queue A is 100, the initial queue priority value of descriptor queue B is 111, and the initial queue priority value of descriptor queue C is 122. The smaller the initial priority value, the higher the queue priority. Assume that when the cumulative amount of data to be processed corresponding to the data descriptors in each descriptor queue is 8192 bytes, the queue priority of the second target descriptor queue is increased.
[0087] During the process of processing the pending data corresponding to the data descriptors in each descriptor queue, if the amount of processed data corresponding to the data descriptors in descriptor queues A and B in stage 1 is 8192 bytes, descriptor queue C is determined as the second target descriptor queue, and the initial queue priority value of descriptor queue C is reduced to 112 to increase the queue priority of descriptor queue C. Furthermore, in stage 2, if the amount of processed data corresponding to the data descriptors in descriptor queues A and B is still 8192 bytes, the queue priority value of descriptor queue C is further reduced to 102 to further increase the queue priority of descriptor queue C. Before the start of stage 3, the queue priority value of descriptor queue C is lower than the queue priority value of descriptor queue B, indicating that the queue priority of descriptor queue C is higher than the queue priority of descriptor queue B, but lower than the queue priority of descriptor queue A. Therefore, in stage 3, the corresponding pending data are processed in the order of descriptor queue A, descriptor queue B, and descriptor queue C.
[0088] Furthermore, in stage 3, since the preset data volume of descriptor queue C is 4096 bytes, and assuming that the cumulative amount of data to be processed corresponding to the data descriptors in each descriptor queue is 8192 bytes, the queue priority is adjusted. Therefore, the maximum amount of data to be processed corresponding to the data descriptors in descriptor queue C is 4096 bytes, and the queue priority value of descriptor queue C is further reduced to 102 to increase the queue priority of descriptor queue C. In stage 4, if the total amount of data to be processed corresponding to the data descriptors in descriptor queue C is 4096 bytes, that is, the data volume threshold of descriptor queue C is reached, the queue priority value of descriptor queue C is restored to the initial queue priority value of 122.
[0089] In some feasible implementations, when processing the pending data corresponding to the data descriptors in each descriptor queue, the pending data can be obtained or transmitted according to the transmission address, acquisition method, etc. contained in the data descriptors in the descriptor queue.
[0090] Alternatively, the data to be processed may be further transmitted and / or analyzed according to other data processing methods in the data descriptor for further data operations. For example, when the data to be processed is control data, after the data to be processed is transmitted according to the data descriptor, the data receiving device may perform operations corresponding to the control data according to the data to be processed.
[0091] Among them, for each descriptor queue, after processing the pending data corresponding to the data descriptors in the descriptor queue in turn according to the first-in-first-out rule of the data descriptors, the descriptor status of the data descriptor corresponding to the processed data can be determined as the executed status, which is used to indicate that the pending data corresponding to the corresponding data descriptor has been processed.
[0092] See also Figure 7 , Figure 7 This is a schematic diagram of the descriptor status provided in an embodiment of the present application. Figure 7 As shown in the figure, after data descriptors Obj_X and Obj_Y enter the descriptor queue, their respective descriptor statuses Obj_status are set to OK, indicating that the corresponding pending data has not been processed. When the Prod_tail pointer detects that the descriptor status Obj_status corresponding to position 4 has been set to cmd_ok, it indicates that the corresponding pending data has been processed and points to position 5.
[0093] When determining whether there is a new data descriptor in any descriptor queue, it is possible to determine whether the Cons_head pointer and the Prod_tail pointer in the descriptor queue point to the same position. If they point to different positions, it means that there is a new data descriptor in the descriptor queue, that is, there is a data descriptor corresponding to the unprocessed data. After processing the data to be processed corresponding to the data descriptor Obj_X, the descriptor status Obj_status[4] of the data descriptor Obj_X can be set from the executable state cmd_ok to the executed state send_ok, and the cons_head pointer points to position 5. When the cons_head pointer and the Prod_tail pointer point to the same position, or the data processed by the descriptor queue meets the first preset condition, switch to other descriptor queues to continue working.
[0094] In an embodiment of the present application, by storing data descriptors in at least two descriptor queues whose queue priorities correspond to the data priorities corresponding to the data descriptors, each descriptor queue can contain a data descriptor corresponding to a data priority, and different descriptor queues correspond to different data priorities. Furthermore, by using the queue priorities corresponding to each descriptor queue, the data to be processed can be processed according to the data priority, which can improve data processing efficiency. Furthermore, by processing the corresponding data to be processed based on the data descriptors in each descriptor queue, mutual interference between the data to be processed can be prevented, and the problem of data priority changes caused by the mutual exclusion of the processes corresponding to the data to be processed can be avoided, which can further reduce data processing time and has high applicability.
[0095] See also Figure 8 , Figure 8 Schematic diagram of the structure of the data processing device provided in the embodiment of the present application. The data processing device 1 provided in the embodiment of the present application includes:
[0096] A descriptor acquisition module 11 is used to obtain the data priority and data descriptor of the data to be processed;
[0097] a descriptor storage module 12 for storing the data descriptors in corresponding queues according to the data priority, wherein the corresponding queues are queues in at least two descriptor queues whose queue priorities correspond to the data priority, and the queue priorities corresponding to the descriptor queues are different;
[0098] The data processing module 13 processes the to-be-processed data corresponding to the data descriptors in each of the above descriptor queues based on the queue priorities of the above descriptor queues.
[0099] In some feasible implementations, the data processing module 13 is configured to:
[0100] When processing the to-be-processed data corresponding to the data descriptor in any descriptor queue, if the first data corresponding to the descriptor queue meets the first preset condition, processing the to-be-processed data corresponding to the data descriptor in the first target descriptor queue;
[0101] Among them, the above-mentioned first data is the processed data in the pending data corresponding to the data descriptor in the descriptor queue, the above-mentioned first target descriptor queue is a descriptor queue with a queue priority lower than the queue priority of the descriptor queue, and a descriptor queue with a queue priority adjacent to the queue priority of the descriptor queue, or the above-mentioned first target descriptor queue is a descriptor queue with a queue priority higher than the descriptor queue and the descriptor queue with the highest queue priority among the descriptor queues corresponding to the second data, and the above-mentioned second data is the unprocessed data in the pending data corresponding to the data descriptor in the descriptor queue.
[0102] In some feasible implementations, the first preset condition is any one of the following:
[0103] The data volume of the first data exceeds a first data volume threshold;
[0104] The number of the first data exceeds a first threshold;
[0105] The processing time corresponding to the first data exceeds a first time threshold.
[0106] In some feasible implementations, the data processing module 13 is further configured to:
[0107] Adjusting the queue priority of the second target descriptor queue according to a preset priority adjustment strategy;
[0108] Based on the adjusted queue priorities of the descriptor queues, processing the to-be-processed data corresponding to the data descriptors in the descriptor queues;
[0109] Wherein, the second target descriptor queue is at least one of the above descriptor queues;
[0110] When the queue priority of the second target descriptor queue is lower than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is increased; when the queue priority of the second target descriptor queue is higher than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is lowered.
[0111] In some feasible implementations, the data processing module 13 is further configured to:
[0112] When the first data corresponding to the third target descriptor queue meets the second preset condition, restoring the queue priority of each of the above descriptor queues to the queue priority before adjustment;
[0113] The third target descriptor queue is at least one of the above descriptor queues, and the queue priority of the third target descriptor queue before adjustment is lower than the queue priority of any of the other descriptor queues before adjustment; the first data is the processed data in the to-be-processed data corresponding to the data descriptor in the descriptor queue;
[0114] The second precondition is any one of the following:
[0115] The amount of the first data exceeds a second data amount threshold;
[0116] The number of the first data exceeds the second threshold;
[0117] The processing time corresponding to the first data exceeds the second time threshold.
[0118] In some feasible implementations, the data processing module 13 is configured to:
[0119] Recording relevant information of the processed data, including any one of the amount, number, and processing time of the processed data;
[0120] Based on the above relevant information, the queue priority of the second target descriptor queue is adjusted;
[0121] Wherein, after each adjustment of the queue priority of the second target descriptor queue, the relevant information of the processed data after the current moment is re-recorded.
[0122] In some feasible implementations, the descriptor storage module 12 is configured to:
[0123] Determine the acquisition time of the above data descriptor;
[0124] The data descriptors are stored in the corresponding queues according to the order of the acquisition time and the data priority;
[0125] Determining the descriptor state of the data descriptor as an executable state, wherein the executable state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has not been processed;
[0126] The data processing module 13 is used to:
[0127] For each descriptor queue, the to-be-processed data corresponding to the data descriptors in the descriptor queue are processed in sequence according to the first-in-first-out rule of the data descriptors;
[0128] The descriptor state of the data descriptor corresponding to the processed data is determined to be an executed state, and the executed state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has been processed.
[0129] In some feasible implementations, the data processing module 13 is further configured to:
[0130] detecting a current state of the processor at a preset time interval;
[0131] If the current state is a sleep state and there is a data descriptor of unprocessed data in any of the descriptor queues, the processor is activated so that the processor processes the pending data corresponding to the data descriptors in each of the descriptor queues based on the data priority corresponding to each of the descriptor queues.
[0132] In some feasible implementations, the data processing module 13 is further configured to:
[0133] If the current state is an active state and there is no data descriptor of unprocessed data in each of the descriptor queues, the processor is controlled to enter a dormant state.
[0134] In a specific implementation, the above-mentioned device 1 can execute the above-mentioned functions through its built-in functional modules. Figure 1 For the implementation methods provided in each step, please refer to the implementation methods provided in the above steps, which will not be repeated here.
[0135] It should be noted here that the above-mentioned device 1 provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.
[0136] See also Figure 9 , Figure 9 Schematic diagram of the structure of the electronic device provided in the embodiment of the present application. Figure 9As shown, the electronic device 1000 in this embodiment may include: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned electronic device 1000 may also include: a user interface 1003, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1004 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may optionally be at least one storage device located away from the aforementioned processor 1001. As Figure 9 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application.
[0137] exist Figure 9 In the electronic device 1000 shown, the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0138] Obtaining the data priority and data descriptor of the data to be processed;
[0139] storing the data descriptors in corresponding queues according to the data priority, the corresponding queues being queues in at least two descriptor queues whose queue priorities correspond to the data priority, the queue priorities corresponding to the descriptor queues being different;
[0140] Based on the queue priorities of the descriptor queues, the to-be-processed data corresponding to the data descriptors in the descriptor queues are processed.
[0141] In some feasible implementations, the processor 1001 is configured to:
[0142] When processing the to-be-processed data corresponding to the data descriptor in any descriptor queue, if the first data corresponding to the descriptor queue meets the first preset condition, processing the to-be-processed data corresponding to the data descriptor in the first target descriptor queue;
[0143] Among them, the above-mentioned first data is the processed data in the pending data corresponding to the data descriptor in the descriptor queue, the above-mentioned first target descriptor queue is a descriptor queue with a queue priority lower than the queue priority of the descriptor queue, and a descriptor queue with a queue priority adjacent to the queue priority of the descriptor queue, or the above-mentioned first target descriptor queue is a descriptor queue with a queue priority higher than the descriptor queue and the descriptor queue with the highest queue priority among the descriptor queues corresponding to the second data, and the above-mentioned second data is the unprocessed data in the pending data corresponding to the data descriptor in the descriptor queue.
[0144] In some feasible implementations, the first preset condition is any one of the following:
[0145] The data volume of the first data exceeds a first data volume threshold;
[0146] The number of the first data exceeds a first threshold;
[0147] The processing time corresponding to the first data exceeds a first time threshold.
[0148] In some feasible implementations, the processor 1001 is further configured to:
[0149] Adjusting the queue priority of the second target descriptor queue according to a preset priority adjustment strategy;
[0150] Based on the adjusted queue priorities of the descriptor queues, processing the to-be-processed data corresponding to the data descriptors in the descriptor queues;
[0151] Wherein, the second target descriptor queue is at least one of the above descriptor queues;
[0152] When the queue priority of the second target descriptor queue is lower than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is increased; when the queue priority of the second target descriptor queue is higher than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is lowered.
[0153] In some feasible implementations, the processor 1001 is further configured to:
[0154] When the first data corresponding to the third target descriptor queue meets the second preset condition, restoring the queue priority of each of the above descriptor queues to the queue priority before adjustment;
[0155] The third target descriptor queue is at least one of the above descriptor queues, and the queue priority of the third target descriptor queue before adjustment is lower than the queue priority of any of the other descriptor queues before adjustment; the first data is the processed data in the to-be-processed data corresponding to the data descriptor in the descriptor queue;
[0156] The second precondition is any one of the following:
[0157] The amount of the first data exceeds a second data amount threshold;
[0158] The number of the first data exceeds the second threshold;
[0159] The processing time corresponding to the first data exceeds the second time threshold.
[0160] In some feasible implementations, the processor 1001 is configured to:
[0161] Recording relevant information of the processed data, including any one of the amount, number, and processing time of the processed data;
[0162] Based on the above relevant information, the queue priority of the second target descriptor queue is adjusted;
[0163] Wherein, after each adjustment of the queue priority of the second target descriptor queue, the relevant information of the processed data after the current moment is re-recorded.
[0164] In some feasible implementations, the processor 1001 is configured to:
[0165] Determine the acquisition time of the above data descriptor;
[0166] The data descriptors are stored in the corresponding queues according to the order of the acquisition time and the data priority;
[0167] Determining the descriptor state of the data descriptor as an executable state, wherein the executable state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has not been processed;
[0168] For each descriptor queue, the to-be-processed data corresponding to the data descriptors in the descriptor queue are processed in sequence according to the first-in-first-out rule of the data descriptors;
[0169] The descriptor state of the data descriptor corresponding to the processed data is determined to be an executed state, and the executed state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has been processed.
[0170] In some feasible implementations, the processor 1001 is further configured to:
[0171] detecting a current state of the processor at a preset time interval;
[0172] If the current state is a sleep state and there is a data descriptor of unprocessed data in any of the descriptor queues, the processor is activated so that the processor processes the pending data corresponding to the data descriptors in each of the descriptor queues based on the data priority corresponding to each of the descriptor queues.
[0173] In some feasible implementations, the processor 1001 is further configured to:
[0174] If the current state is an active state and there is no data descriptor of unprocessed data in each of the descriptor queues, the processor is controlled to enter a dormant state.
[0175] It should be understood that in some feasible embodiments, the processor 1001 may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, etc. The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store device type information.
[0176] In a specific implementation, the electronic device 1000 can execute the above-mentioned functions through its built-in functional modules. Figure 1 For the implementation methods provided in each step, please refer to the implementation methods provided in the above steps, which will not be repeated here.
[0177] In an embodiment of the present application, by storing data descriptors in at least two descriptor queues whose queue priorities correspond to the data priorities corresponding to the data descriptors, each descriptor queue can contain a data descriptor corresponding to a data priority, and different descriptor queues correspond to different data priorities. Furthermore, by using the queue priorities corresponding to each descriptor queue, the data to be processed can be processed according to the data priority, which can improve data processing efficiency. Furthermore, by processing the corresponding data to be processed based on the data descriptors in each descriptor queue, mutual interference between the data to be processed can be prevented, and the problem of data priority changes caused by the mutual exclusion of the processes corresponding to the data to be processed can be avoided, which can further reduce data processing time and has high applicability.
[0178] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program and is executed by a processor to implement the method provided by the embodiment of the present application. For details, please refer to the implementation methods provided in the above steps, which will not be repeated here.
[0179] The above-mentioned computer-readable storage medium can be the internal storage unit of the task processing device provided by any of the aforementioned embodiments, such as the hard disk or memory of the electronic device. The computer-readable storage medium can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. The above-mentioned computer-readable storage medium can also include a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. Further, the computer-readable storage medium can also include both the internal storage unit of the electronic device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the electronic device. The computer-readable storage medium can also be used to temporarily store data that has been output or is to be output.
[0180] The present invention provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in the present invention.
[0181] The terms "first," "second," and the like in the claims, specification, and drawings of this application are used to distinguish between different objects, not to describe a specific order. Furthermore, the terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or electronic device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such process, method, product, or electronic device. Reference herein to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The presence of such a phrase in various locations in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive with other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments. The term "and / or," as used in this specification and the appended claims, refers to any and all possible combinations of one or more of the associated listed items, including, but not limited to, those combinations.
[0182] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the above description generally describes the components and steps of each example according to their functions. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0183] The above disclosure is only a preferred embodiment of the present application and cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining the data priority and data descriptor of the data to be processed; storing the data descriptor in a corresponding queue according to the data priority, the corresponding queue being a queue of at least two descriptor queues whose queue priority corresponds to the data priority, and the queue priorities corresponding to the descriptor queues being different; Based on the queue priorities of the descriptor queues, the to-be-processed data corresponding to the data descriptors in the descriptor queues are processed; when processing the to-be-processed data corresponding to the data descriptors in any descriptor queue, if the first data corresponding to the descriptor queue meets the first preset condition, the to-be-processed data corresponding to the data descriptors in the first target descriptor queue are processed; The first data is the processed data in the pending data corresponding to the data descriptor in the descriptor queue, the first target descriptor queue is a descriptor queue whose queue priority is lower than the queue priority of the descriptor queue, and whose queue priority is adjacent to the queue priority of the descriptor queue, or the first target descriptor queue is a descriptor queue whose queue priority is higher than the descriptor queue and has the highest queue priority among the descriptor queues corresponding to the second data, and the second data is the unprocessed data in the pending data corresponding to the data descriptor in the descriptor queue.
2. The method according to claim 1, characterized in that The first preset condition is any one of the following: The data volume of the first data exceeds a first data volume threshold; The number of the first data exceeds a first number threshold; The processing time corresponding to the first data exceeds a first time threshold.
3. The method according to claim 1, characterized in that The method further comprises: Adjusting the queue priority of the second target descriptor queue according to a preset priority adjustment strategy; Based on the adjusted queue priorities of the descriptor queues, processing the to-be-processed data corresponding to the data descriptors in the descriptor queues; wherein the second target descriptor queue is at least one of the descriptor queues; The adjusting the queue priority of the second target descriptor queue includes: When the queue priority of the second target descriptor queue is lower than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is increased; when the queue priority of the second target descriptor queue is higher than the queue priority of any descriptor queue in the other descriptor queues, the queue priority of the second target descriptor queue is lowered.
4. The method according to claim 3, characterized in that The method further comprises: When the first data corresponding to the third target descriptor queue meets the second preset condition, restoring the queue priority of each descriptor queue to the queue priority before adjustment; The third target descriptor queue is at least one of the descriptor queues, and the queue priority of the third target descriptor queue before adjustment is lower than the queue priority of any descriptor queue in the other descriptor queues before adjustment; the first data is processed data in the to-be-processed data corresponding to the data descriptor in the descriptor queue; The second preset condition is any one of the following: The data volume of the first data exceeds a second data volume threshold; The number of the first data exceeds a second number threshold; The processing time corresponding to the first data exceeds a second time threshold.
5. The method according to claim 3, characterized in that The step of adjusting the queue priority of the second target descriptor queue according to a preset priority adjustment strategy includes: Recording relevant information of the processed data, including any one of the amount, number, and processing time of the processed data; Adjusting the queue priority of the second target descriptor queue based on the relevant information; Wherein, after each adjustment of the queue priority of the second target descriptor queue, the relevant information of the processed data after the current moment is re-recorded.
6. The method according to claim 1, characterized in that The storing the data descriptor into a corresponding queue according to the data priority includes: Determining an acquisition time of the data descriptor; The data descriptors are stored in corresponding queues according to the order of the acquisition time and the data priority; Determining a descriptor state of the data descriptor as an executable state, wherein the executable state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has not been processed; The processing of the to-be-processed data corresponding to the data descriptors in each of the descriptor queues includes: For each descriptor queue, the to-be-processed data corresponding to the data descriptors in the descriptor queue are processed in sequence according to the first-in-first-out rule of the data descriptors; The descriptor state of the data descriptor corresponding to the processed data is determined to be an executed state, where the executed state is used to indicate that the to-be-processed data corresponding to the corresponding data descriptor has been processed.
7. The method according to any one of claims 1 to 6, characterized in that The method is executed by a processor, and further includes: detecting a current state of the processor at preset time intervals; If the current state is a sleep state and there is a data descriptor of unprocessed data in any of the descriptor queues, the processor is activated so that the processor processes the to-be-processed data corresponding to the data descriptors in each of the descriptor queues based on the data priority corresponding to each of the descriptor queues.
8. The method according to claim 7, characterized in that Said also includes: If the current state is an active state and there is no data descriptor of unprocessed data in each of the descriptor queues, the processor is controlled to enter a sleep state.
9. A data processing device, characterized in that: The device comprises: A descriptor acquisition module is used to obtain the data priority and data descriptor of the data to be processed; a descriptor storage module, configured to store the data descriptor in a corresponding queue according to the data priority, wherein the corresponding queue is a queue in at least two descriptor queues whose queue priority corresponds to the data priority, and the queue priorities corresponding to the descriptor queues are different; a data processing module, configured to process the pending data corresponding to the data descriptors in each of the descriptor queues based on the queue priority of each of the descriptor queues; and when processing the pending data corresponding to the data descriptors in any descriptor queue, if the first data corresponding to the descriptor queue meets a first preset condition, processing the pending data corresponding to the data descriptors in the first target descriptor queue; The first data is the processed data in the pending data corresponding to the data descriptor in the descriptor queue, the first target descriptor queue is a descriptor queue whose queue priority is lower than the queue priority of the descriptor queue, and whose queue priority is adjacent to the queue priority of the descriptor queue, or the first target descriptor queue is a descriptor queue whose queue priority is higher than the descriptor queue and has the highest queue priority among the descriptor queues corresponding to the second data, and the second data is the unprocessed data in the pending data corresponding to the data descriptor in the descriptor queue.
10. An electronic device, characterized in that: comprising a processor and a memory, wherein the processor and the memory are connected to each other; The memory is used to store computer programs; The processor is configured to execute the method according to any one of claims 1 to 8 when calling the computer program.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Message processing method used for cloud storage system and device thereof
CN105763608A
Data processing method, device and system and DMA controller
CN109766296A
Task processing method and device, electronic equipment and machine readable storage medium
CN111552548A
Mutli-priority command processing among microcontrollers
US20110321052A1