A dynamic priority data processing scheduling method in an embedded bare metal environment

By adopting a dynamic scheduling algorithm based on priority and buffer margin in an embedded bare-metal environment, the problem of mutual influence between data processing modules is solved, the reliability and real-time performance of data processing are improved, and buffer overflow is avoided.

CN120469785BActive Publication Date: 2025-09-09TIANJIN QINEN COMM TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510968781.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-15
Publication Date
2025-09-09
Estimated Expiration
2045-07-15

AI Technical Summary

Technical Problem

In embedded systems, especially in bare-metal environments with low-performance MCUs, data processing modules affect each other, affecting the timeliness of data processing on high-real-time interfaces. Low-priority data may not be processed for a long time, causing buffer overflow.

Method used

A dynamic scheduling algorithm based on priority and buffer margin is adopted. By initializing and prioritizing the data buffer, the priority of the data buffer is dynamically adjusted. By combining the ring queue and the scheduling queue, the buffer that has not triggered the margin alarm is processed first to avoid buffer overflow.

Benefits of technology

Improves the data processing reliability and real-time performance in bare metal environments, ensures the real-time performance of data on each interface and balanced management of the buffer, and avoids buffer overflow.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120469785B_ABST
    Figure CN120469785B_ABST
Patent Text Reader

Abstract

The present invention discloses a dynamic priority data processing scheduling method in an embedded bare metal environment, the method comprising: initializing a data buffer, configuring a priority, and adding the data buffer to a priority array; obtaining received data and uploading it to a corresponding data buffer, and updating a buffer margin of a buffer space of the data buffer; when the buffer margin triggers a margin alarm, adjusting a margin alarm flag, increasing a margin alarm count, and adding the data buffer to a margin queue; dynamically adjusting the priority of the data buffer according to the margin alarm count; polling data buffers in the priority array that have not triggered a margin alarm in sequence according to priority, and adding non-empty data buffers to a scheduling queue; when the margin queue is not empty, processing the data buffers in the margin queue in sequence, and when the margin queue is empty, processing the data buffers in the scheduling queue in sequence; the present invention can effectively improve the reliability and real-time performance of data processing in a bare metal environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and more specifically, to a dynamic priority data processing scheduling method in an embedded bare metal environment. Background Art

[0002] In embedded system applications, especially for lower-performance MCUs, software development often relies on bare-metal (no operating system) development. Interface data processing software in bare-metal environments, without operating system scheduling, can easily interfere with each other's data processing modules. For example, if a low-real-time interface frequently processes data, it consumes significant CPU resources and often impacts the timely processing of data from other high-real-time interfaces. Alternatively, if data is processed based on priority, low-priority data may remain unprocessed for extended periods, leading to buffer overflows.

[0003] Therefore, the prior art has defects and is in urgent need of improvement. Summary of the Invention

[0004] In view of the above problems, the purpose of the present invention is to provide a dynamic priority data processing scheduling method in an embedded bare metal environment. The priority-based data buffer scheduling framework can efficiently manage multi-channel received data in the bare metal environment, providing convenient support for the development of data processing applications. A receiving buffer is added to each interface data and a priority is set. Through a dynamic priority scheduling algorithm based on priority + buffer margin, the real-time performance of each interface data and the avoidance of buffer overflow are taken into account. A balance is achieved as much as possible between ensuring priority and avoiding data buffer overflow, which can effectively improve the reliability and real-time performance of data processing in a bare metal environment (without an operating system).

[0005] A first aspect of the present invention provides a dynamic priority data processing scheduling method in an embedded bare metal environment, comprising:

[0006] Step 1: Initialize the data buffer corresponding to each hardware interface and configure a unique priority, and add each data buffer to the priority array in ascending order of priority;

[0007] Step 2: Obtain the received data received by the hardware interface;

[0008] Step 3: uploading the received data to the corresponding data buffer based on the hardware interface, and updating the buffer margin of the buffer space of the data buffer;

[0009] Step 4: When the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjust the margin alarm flag, increase the margin alarm count, and add the data buffer to the margin queue; dynamically adjust the priority of the data buffer according to the margin alarm count of the data buffer;

[0010] Step 5: poll the data buffers in the priority array that have not triggered the margin alarm in order of priority, and add the non-empty data buffers to the scheduling queue;

[0011] Step 6: When the remaining queue is not empty, the data buffers in the remaining queue are processed in sequence; when the remaining queue is empty, the data buffers in the scheduling queue are processed in sequence;

[0012] Step 7: When both the remaining queue and the scheduling queue are empty, return to step 5.

[0013] This plan also includes:

[0014] The structure of the data buffer is a circular queue;

[0015] The data structure of the ring queue includes a data buffer, a sending and receiving pointer, a buffer size, a priority, a remaining amount alarm flag and a remaining amount alarm count.

[0016] In this solution, the initialization of the data buffer corresponding to each hardware interface includes:

[0017] Setting a buffer size of the data buffer and allocating buffer space according to the buffer size;

[0018] Set the transmit and receive pointers to 0, set the remaining amount alarm flag to 0, and set the remaining amount alarm count to 0.

[0019] This plan also includes:

[0020] When the data buffer in the margin queue or the scheduling queue is processed, the buffer margin of the buffer space of the data buffer is updated, and the margin alarm flag is set to 0.

[0021] In this solution, when the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjusting the margin alarm flag and increasing the margin alarm count includes:

[0022] When the margin alarm flag of the data buffer is 0 and the buffer margin of the buffer space is less than 1 / 2, the margin alarm is triggered;

[0023] After the margin alarm is triggered, the margin alarm flag of the corresponding data buffer area is adjusted to 1;

[0024] When the remaining amount warning flag of the data buffer is 1, the remaining amount warning count of the data buffer area is increased, and the remaining amount warning flag of the data buffer area is reset.

[0025] In this solution, the step of dynamically adjusting the priority of the data buffer according to the remaining alarm count of the data buffer includes:

[0026] When the remaining alarm count of any data buffer is greater than the first preset count threshold M1, the data buffer is determined as the first data buffer Q X , the corresponding priority is X;

[0027] The data buffer corresponding to the priority X-1 in the priority array is determined as the second data buffer Q X-1 , read the second data buffer Q X-1 The remaining alarm count M X-1 ;

[0028] When X-1<0, give up adjustment;

[0029] When M X-1 <M2, exchange the first data buffer Q X and the second data buffer Q X-1 Priority, exchange the first data buffer Q X and the second data buffer Q X-1 position in the priority array and the first data buffer Q X and the second data buffer Q X-1 The remaining alarm count is cleared; wherein M2 is a second preset counting threshold, M2<M1;

[0030] When M X-1 ≥M2, traverse forward based on the priority, read the remaining alarm counts of the data buffers corresponding to each priority in turn, and determine the first data buffer with a remaining alarm count less than M2 as the third data buffer M START , the corresponding priority is START;

[0031] Determine priority X as priority END;

[0032] Adjust the priority of the data buffer corresponding to the priority interval from priority START to priority END;

[0033] If there is no data buffer with a margin alarm count less than M2 in the data buffer corresponding to priority 0, the adjustment is abandoned.

[0034] In this solution, the priority adjustment of the data buffer corresponding to the priority interval from priority START to priority END includes:

[0035] The priority START corresponds to the third data buffer M STARTThe priority of the data buffers corresponding to priority START+1 to priority END is adjusted to END, and the priorities of the data buffers corresponding to priority START+1 to priority END are all increased by one level. The positions of the data buffers corresponding to the priority interval from priority START to priority END in the priority array are updated based on the priority, and the remaining alarm count of the data buffers corresponding to the priority interval from priority START to priority END is cleared to zero.

[0036] The present invention discloses a dynamic priority data processing scheduling method in an embedded bare metal environment, the method comprising: initializing a data buffer, configuring a priority, and adding the data buffer to a priority array; obtaining received data and uploading it to a corresponding data buffer, and updating a buffer margin of a buffer space of the data buffer; when the buffer margin triggers a margin alarm, adjusting a margin alarm flag, increasing a margin alarm count, and adding the data buffer to a margin queue; dynamically adjusting the priority of the data buffer according to the margin alarm count; polling data buffers in the priority array that have not triggered a margin alarm in sequence according to priority, and adding non-empty data buffers to a scheduling queue; when the margin queue is not empty, processing the data buffers in the margin queue in sequence, and when the margin queue is empty, processing the data buffers in the scheduling queue in sequence; the present invention can effectively improve the reliability and real-time performance of data processing in a bare metal environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A flow chart of a dynamic priority data processing and scheduling method in an embedded bare metal environment provided by the present invention is shown;

[0038] Figure 2 A flow chart showing a method for processing when a buffer margin of a buffer space in a data buffer area triggers a margin alarm provided by the present invention is shown;

[0039] Figure 3 The figure shows a structural diagram of the data buffer scheduling framework provided by the present invention. DETAILED DESCRIPTION

[0040] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.

[0041] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.

[0042] Figure 1The flowchart of the dynamic priority data processing scheduling method in an embedded bare metal environment provided by the present invention is shown.

[0043] like Figure 1 As shown, the present invention discloses a dynamic priority data processing scheduling method in an embedded bare metal environment, comprising:

[0044] S102, step 1, initialize the data buffer corresponding to each hardware interface, configure a unique priority, and add each data buffer to the priority array in ascending order of priority;

[0045] S104, step 2, obtaining the received data received by the hardware interface;

[0046] S106, step three, uploading the received data to the corresponding data buffer based on the hardware interface, and updating the buffer margin of the buffer space of the data buffer;

[0047] S108, step 4, when the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjusting the margin alarm flag, increasing the margin alarm count, and adding the data buffer to the margin queue; dynamically adjusting the priority of the data buffer according to the margin alarm count of the data buffer;

[0048] S110, step 5, polling the data buffers in the priority array that have not triggered the margin alarm in order of priority, and adding the non-empty data buffers to the scheduling queue;

[0049] S112, step six, when the surplus queue is not empty, the data buffers in the surplus queue are processed in sequence; when the surplus queue is empty, the data buffers in the scheduling queue are processed in sequence;

[0050] S114, step seven, when both the remaining queue and the scheduling queue are empty, return to step five.

[0051] According to an embodiment of the present invention, Figure 3 As shown in the figure, a general priority-based data buffer scheduling framework is first designed, which includes the data structure of the data buffer, the organization and sorting of the data buffer, the scheduler 5, the data processing program 6, and the hardware interface interrupt 7. Among them, the priority array 1, the data buffers in the data buffer group 2, the scheduling queue 3, and the margin queue 4 are all circular queues. In the figure, W is the write pointer of each queue, and R is the read pointer of each queue.

[0052] Data buffers are implemented as a circular queue, the size of which can be configured during initialization. The circular queue data structure contains the data buffer, send and receive pointers, buffer size, priority, margin warning flag, and margin warning count. Each hardware interface corresponds to a unique data buffer, and each data buffer has a unique priority. The system pre-set priority range is 0 to 31, with 0 being the highest priority and 31 being the lowest. Margin warnings: The value is 1 when the buffer margin is less than 1 / 2 and 0 when the buffer margin is greater than 3 / 4. A margin warning value of 1 indicates a margin warning. During initialization, the margin levels of all data buffers are set to 0. Data buffer organization and sorting: The priority array stores all data buffers, indexed by the data buffer's priority. The margin queue stores data buffers with a margin warning flag of 1 in a circular queue. The scheduler processes data buffers in the priority array that have not experienced margin warnings according to their priority level and places non-empty data buffers into the scheduling queue. The data processing program prioritizes the margin queue. If the margin queue is empty, it processes the data from each data buffer in the scheduling queue one by one. After processing, the transmit and receive pointers and the margin alarm flag of the data buffer are updated.

[0053] When implementing the dynamic priority data processing scheduling method, a unique priority is first determined for all hardware interfaces. The corresponding data buffer structure is initialized, the buffer size is set, buffer space is allocated, the send and receive pointers are set to 0, the margin alarm flag is set to 0, and the margin alarm count is set to 0. Priority is configured, and the data buffer is filled into a priority array according to the priority. After the hardware interface interrupt places newly received data into the corresponding data buffer, the buffer margin of the data buffer space is updated. When the buffer margin of the data buffer space triggers a margin alarm (i.e., the margin alarm flag is 0 and the buffer margin is less than 1 / 2), the margin alarm flag of the data buffer is adjusted to 1, the margin alarm count of the data buffer is increased by 1, and the margin alarm flag of the data buffer is reset. Simultaneously, the buffer queue is placed in the margin queue. Furthermore, the priority of each data buffer is dynamically adjusted according to the margin alarm count of the data buffer. In the main loop, when the balance queue is not empty, the data buffers in the balance queue are processed in the order of entering the balance queue. After processing, the data buffer area send and receive pointers are updated and the balance alarm flag is cleared; when the balance queue is empty, the data of each data buffer in the scheduling queue is processed in sequence according to priority. After processing, the data buffer area send and receive pointers are updated and the balance alarm flag is cleared; when the balance queue is empty and the scheduling queue is also empty, the data buffers with a balance alarm flag of 0 are queried in sequence according to the order of the priority array, and the non-empty data buffer pointers are placed in the scheduling queue; repeat the above steps to complete the data processing scheduling.

[0054] In addition, a corresponding data buffer pointer can be generated according to the starting memory address of the data buffer, and the data buffer pointer can be used to replace the data buffer to be added to the priority array, the margin queue and the scheduling queue. When the data buffer is processed, the corresponding data buffer is accessed according to the data buffer pointer for data processing.

[0055] According to an embodiment of the present invention, the further embodiment includes:

[0056] The structure of the data buffer is a circular queue;

[0057] The data structure of the ring queue includes data buffer, sending and receiving pointers, buffer size, priority, margin alarm flag and margin alarm count.

[0058] It should be noted that the data buffer is implemented as a circular queue, and the queue size can be configured during initialization. The circular queue data structure includes the data buffer, send and receive pointers, buffer size, priority, margin warning flag, and margin warning count. Each received data channel (received by a different hardware interface) corresponds to a data buffer. The system has 32 preset priorities, 0-31, with 0 being the highest and 31 being the lowest. Each priority corresponds to a separate data buffer. The margin warning flags can be 0 or 1.

[0059] According to an embodiment of the present invention, initializing the data buffer corresponding to each hardware interface includes:

[0060] Set the buffer size of the data buffer and allocate buffer space according to the buffer size;

[0061] Set the transmit and receive pointers to 0, set the remaining amount alarm flag to 0, and set the remaining amount alarm count to 0.

[0062] It should be noted that the buffer size is set by those skilled in the art according to actual needs, such as Figure 3 As shown, the data buffer sizes corresponding to priority 0, priority 21, and priority 31 are 128, 256, and 256, respectively. The data buffer size is equal to the preset buffer size. The transmit and receive pointers, margin alarm flag, and margin alarm count are reset to 0.

[0063] According to an embodiment of the present invention, the further embodiment includes:

[0064] When the data buffer in the margin queue or the scheduling queue is processed, the buffer margin of the buffer space of the data buffer is updated and the margin alarm flag is set to 0.

[0065] It should be noted that when the data buffer in the balance queue or scheduling queue is processed, the buffer margin of the buffer space of the data buffer is reset to 0, and the margin alarm flag is set to 0, which means that the received data in the data buffer has been processed and restored to its initial state for receiving new received data.

[0066] Figure 2 The flowchart of the method for processing when the buffer margin of the buffer space of the data buffer area triggers a margin alarm provided by the present invention is shown.

[0067] like Figure 2 As shown, according to an embodiment of the present invention, when the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjusting the margin alarm flag and increasing the margin alarm count includes:

[0068] S202, when the margin alarm flag of the data buffer is 0 and the buffer margin of the buffer space is less than 1 / 2, triggering a margin alarm;

[0069] S204, after the remaining amount alarm is triggered, the remaining amount alarm flag of the corresponding data buffer area is adjusted to 1;

[0070] S206 , when the remaining amount warning flag of the data buffer is 1, increase the remaining amount warning count of the data buffer area and reset the remaining amount warning flag of the data buffer area.

[0071] It should be noted that the data buffer's margin alarm flag includes 0 and 1, and the system sets corresponding judgment conditions for each. When the buffer margin of the data buffer's buffer space is less than 1 / 2, the margin alarm flag is 1; when the buffer margin is greater than 3 / 4, the margin alarm flag is 0. Therefore, when the buffer margin of the data buffer's buffer space is less than 1 / 2, if the margin alarm flag of the data buffer is 0, the margin alarm flag is adjusted to 1, the margin alarm count of the data buffer is increased by 1, and then the margin alarm flag of the data buffer is reset.

[0072] According to an embodiment of the present invention, dynamically adjusting the priority of a data buffer according to a remaining alarm count of the data buffer includes:

[0073] When the remaining alarm count of any data buffer is greater than the first preset count threshold M1, the data buffer is determined as the first data buffer Q X , the corresponding priority is X;

[0074] The data buffer corresponding to the priority X-1 in the priority array is determined as the second data buffer Q X-1 , read the second data buffer Q X-1 The remaining alarm count M X-1 ;

[0075] When X-1<0, give up adjustment;

[0076] When M X-1 When <M2, exchange the first data buffer Q X and the second data buffer Q X-1 Priority, exchange the first data buffer Q X and the second data buffer Q X-1 The position in the priority array and the first data buffer Q X and the second data buffer Q X-1 The remaining alarm count is cleared; wherein M2 is a second preset counting threshold, M2<M1;

[0077] When M X-1 ≥M2, traverse forward based on the priority, read the remaining alarm counts of the data buffers corresponding to each priority in turn, and determine the first data buffer with a remaining alarm count less than M2 as the third data buffer M START , the corresponding priority is START;

[0078] Determine priority X as priority END;

[0079] Adjust the priority of the data buffer corresponding to the priority interval from priority START to priority END;

[0080] If there is no data buffer with a margin alarm count less than M2 in the data buffer corresponding to priority 0, the adjustment is abandoned.

[0081] It should be noted that the first preset counting threshold M1 and the second preset counting threshold M2 are set by those skilled in the art according to actual needs. The initial value of M1 is 128, and the initial value of M2 is 32.

[0082] The margin alarm count of the data buffer will be accumulated according to whether the margin alarm is triggered during each polling process. By monitoring the margin alarm count of each data buffer, when the margin alarm count of any data buffer is greater than the first preset count threshold M1, the data buffer is determined as the first data buffer M. X , will be larger than the first data buffer M X The data buffer with a higher priority is determined as the second data buffer Q X-1 When X-1<0, it means the first data buffer Q corresponding to the priority X X The data buffer with the highest priority is X=0, and no priority adjustment is required. X-1 When <M2, the first data buffer Q is processed first X , the first data buffer Q XThe priority of the second data buffer Q is adjusted to X-1. X-1 The priority of the two data buffers is adjusted to X to ensure that the priority of the two data buffers is still unique after the adjustment. Based on the priority, the positions of the two data buffers in the priority array are adjusted and the margin alarm counts of the two data buffers are cleared. X-1 <M2, based on the priority, the data in the first data buffer M in the priority array is sent to the X The previous data buffers are traversed, and the first data buffer with the first margin alarm count less than M2 is determined as the third data buffer M START , the third data buffer M START The priority of the first data buffer M is determined to be START, that is, the priority of the start is adjusted. X Priority X is determined as priority END, the final priority for adjustment. The positions of the data buffers corresponding to the priority interval from priority START to priority END in the priority array are adjusted. If no data buffers up to and including priority 0 have a margin warning count less than M2, this indicates that the margin warning counts for the data buffers corresponding to priority 0 through priority X are all high, and adjustment of the data buffer positions is abandoned.

[0083] According to an embodiment of the present invention, priority adjustment is performed on a data buffer corresponding to a priority interval from priority START to priority END, including:

[0084] The priority START corresponds to the third data buffer M START The priority of the data buffers corresponding to priority START+1 to priority END is adjusted to END, and the priorities of the data buffers corresponding to priority START+1 to priority END are all increased by one level. The positions of the data buffers corresponding to the priority interval from priority START to priority END in the priority array are updated based on the priority, and the remaining alarm count of the data buffers corresponding to the priority interval from priority START to priority END is cleared to zero.

[0085] It should be noted that the position of the data buffer corresponding to the priority interval from priority START to priority END in the priority array is adjusted, and priority START to priority END is determined as the priority interval that needs priority adjustment, and the third data buffer M START The priority of the data buffer to be adjusted is set to END, and the priorities of all other data buffers in the adjustment queue are increased by one level to ensure that the adjusted data buffer remains unique after the adjustment. The corresponding data buffers in the adjustment queue are repositioned according to their priorities. Similarly, the remaining alarm counts of the data buffers involved in the adjustment are cleared to zero to avoid frequent adjustments to these data buffers.

[0086] The information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals (including but not limited to signals transmitted between user terminals and other devices, etc.) involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the "received data received by the hardware interface" involved in this disclosure is obtained with full authorization.

[0087] The present invention discloses a dynamic priority data processing scheduling method in an embedded bare metal environment, the method comprising: initializing a data buffer, configuring a priority, and adding the data buffer to a priority array; obtaining received data and uploading it to a corresponding data buffer, and updating a buffer margin of a buffer space of the data buffer; when the buffer margin triggers a margin alarm, adjusting a margin alarm flag, increasing a margin alarm count, and adding the data buffer to a margin queue; dynamically adjusting the priority of the data buffer according to the margin alarm count; polling data buffers in the priority array that have not triggered a margin alarm in sequence according to priority, and adding non-empty data buffers to a scheduling queue; when the margin queue is not empty, processing the data buffers in the margin queue in sequence, and when the margin queue is empty, processing the data buffers in the scheduling queue in sequence; the present invention can effectively improve the reliability and real-time performance of data processing in a bare metal environment.

[0088] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0089] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0090] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0091] Those skilled in the art will appreciate that all or part of the steps of the above-mentioned method embodiments may be implemented by hardware associated with program instructions, and the aforementioned program may be stored in a computer-readable storage medium. When the program is executed, the program executes the steps of the above-mentioned method embodiments. The aforementioned storage medium includes various media that can store program codes, such as mobile storage devices, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0092] Alternatively, if the integrated units described above are implemented as software modules and sold or used as standalone products, they can also be stored on a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present invention, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product, stored on a storage medium, includes instructions for enabling a computer device (such as a personal computer, server, or network device) to execute all or part of the methods described in various embodiments of the present invention. The aforementioned storage media include various media capable of storing program code, such as removable storage devices, ROM, RAM, magnetic disks, or optical disks.

Claims

1. A dynamic priority data processing scheduling method in an embedded bare metal environment, characterized in that: include: Step 1: Initialize the data buffer corresponding to each hardware interface and configure a unique priority, and add each data buffer to the priority array in ascending order of priority; Step 2: Obtain the received data received by the hardware interface; Step 3: uploading the received data to the corresponding data buffer based on the hardware interface, and updating the buffer margin of the buffer space of the data buffer; Step 4: When the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjust the margin alarm flag, increase the margin alarm count, and add the data buffer to the margin queue; dynamically adjust the priority of the data buffer according to the margin alarm count of the data buffer; Step 5: poll the data buffers in the priority array that have not triggered the margin alarm in order of priority, and add the non-empty data buffers to the scheduling queue; Step 6: When the remaining queue is not empty, the data buffers in the remaining queue are processed in sequence; when the remaining queue is empty, the data buffers in the scheduling queue are processed in sequence; Step 7: When both the remaining queue and the scheduling queue are empty, return to step 5.

2. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 1, characterized in that: Also includes: The structure of the data buffer is a circular queue; The data structure of the ring queue includes a data buffer, a sending and receiving pointer, a buffer size, a priority, a remaining amount alarm flag and a remaining amount alarm count.

3. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 2, characterized in that: Initializing the data buffer corresponding to each hardware interface includes: Setting a buffer size of the data buffer and allocating buffer space according to the buffer size; Set the transmit and receive pointers to 0, set the remaining amount alarm flag to 0, and set the remaining amount alarm count to 0.

4. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 1, characterized in that: Also includes: When the data buffer in the margin queue or the scheduling queue is processed, the buffer margin of the buffer space of the data buffer is updated, and the margin alarm flag is set to 0.

5. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 1, characterized in that: When the buffer margin of the buffer space of the data buffer triggers a margin alarm, adjusting the margin alarm flag and increasing the margin alarm count includes: When the margin alarm flag of the data buffer is 0 and the buffer margin of the buffer space is less than 1 / 2, the margin alarm is triggered; After the margin alarm is triggered, the margin alarm flag of the corresponding data buffer area is adjusted to 1; When the remaining amount warning flag of the data buffer is 1, the remaining amount warning count of the data buffer area is increased, and the remaining amount warning flag of the data buffer area is reset.

6. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 1, characterized in that: The dynamically adjusting the priority of the data buffer according to the margin alarm count of the data buffer includes: When the remaining alarm count of any data buffer is greater than the first preset count threshold M1, the data buffer is determined as the first data buffer Q X , the corresponding priority is X; The data buffer corresponding to the priority X-1 in the priority array is determined as the second data buffer Q X-1 , read the second data buffer Q X-1 The remaining alarm count M X-1 ; When X-1<0, give up adjustment; When M X-1 <M2, exchange the first data buffer Q X and the second data buffer Q X-1 Priority, exchange the first data buffer Q X and the second data buffer Q X-1 position in the priority array and the first data buffer Q X and the second data buffer Q X-1 The remaining alarm count is cleared; wherein M2 is a second preset counting threshold, M2<M1; When M X-1 ≥M2, traverse forward based on the priority, read the remaining alarm counts of the data buffers corresponding to each priority in turn, and determine the first data buffer with a remaining alarm count less than M2 as the third data buffer M START , the corresponding priority is START; Determine priority X as priority END; Adjust the priority of the data buffer corresponding to the priority interval from priority START to priority END; If there is no data buffer with a margin alarm count less than M2 in the data buffer corresponding to priority 0, the adjustment is abandoned.

7. The dynamic priority data processing scheduling method in an embedded bare metal environment according to claim 6, characterized in that: The step of adjusting the priority of the data buffer corresponding to the priority interval from priority START to priority END includes: The priority START corresponds to the third data buffer M START The priority of the data buffers corresponding to priority START+1 to priority END is adjusted to END, and the priorities of the data buffers corresponding to priority START+1 to priority END are all increased by one level. The positions of the data buffers corresponding to the priority interval from priority START to priority END in the priority array are updated based on the priority, and the remaining alarm count of the data buffers corresponding to the priority interval from priority START to priority END is cleared to zero.

Citation Information

Patent Citations

  • Alarm data processing method and network management device

    CN105306232A

  • Global queue adjustment method, service flow queue adjustment method and network system

    CN106453141A