Hybrid scheduling method based on containerized hybrid key system
By adopting a mixed scheduling method based on periodic and time slices and an embedded general scheduling algorithm in containerized hybrid key systems, the problem of not being able to guarantee the minimum response time of real-time tasks in the prior art is solved, and a more timely real-time task response is achieved.
Patent Information
- Application Number
- CN202411901590.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-23
AI Technical Summary
Existing hierarchical scheduling strategies for real-time containers cannot guarantee the minimum response time of real-time tasks, especially when real-time tasks with high priority are not necessarily in the shortest-limited control group.
A hybrid scheduling method based on containerized hybrid key systems is proposed. By using a secondary real-time scheduling algorithm based on cycle and time slices in real-time containers, and using embedded general scheduling algorithms in non-real-time containers, the response time of real-time tasks is ensured.
By completely isolating real-time container scheduling from non-real-time container scheduling from the time slice, we ensure preemptive scheduling of critical tasks over non-critical tasks, and ensure that the response time of real-time tasks is more timely.
Smart Images

Figure CN119829244A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of embedded real-time operating systems, and in particular to a hybrid scheduling method based on a containerized hybrid critical system. Background Art
[0002] On the same hardware platform, real-time containers that only run real-time tasks and non-real-time containers that only run non-real-time tasks are integrated. They have different criticality and time constraints. We call such a system a containerized mixed-criticality system.
[0003] In containerized mixed-criticality systems, it is necessary to ensure the determinism and real-time performance of real-time tasks in real-time containers, while ensuring that non-real-time containers can respond within a limited time without starvation. How to reasonably schedule real-time containers and non-real-time containers has become an important issue.
[0004] The article "Container Scheduling Architecture Design Based on Hybrid Criticality System" published in the journal "Computer Science" No. 6, 2023 proposed a container scheduling management mechanism for hybrid criticality systems. Based on the hierarchical scheduling model, the real-time running queue of the container control group (which can be understood as a process group) is scheduled to ensure the real-time performance of each real-time container, and the container resources allocated to non-real-time containers are limited. Load monitoring and balancing strategies are added, and they are reasonably allocated to non-real-time containers according to the dynamic adjustment algorithm. In this way, while ensuring the real-time performance of real-time containers, non-real-time containers can also be responded to within a limited time, and there will be no situation of "starvation" caused by continuous preemption.
[0005] In the hierarchical scheduling concept mentioned in the above literature, all container control groups are associated with clearly specified run time and cycle, and the SCHED_DEADLINE scheduling policy limits the CPU occupied by real-time tasks in the control group to a threshold value of the control group CPU utilization (i.e., the ratio of the specified run time and cycle). For real-time containers, a hierarchical scheduling mechanism is adopted, which is a two-level scheduling hierarchy. The first level uses the SCHED_DEADLINE scheduling policy to be responsible for container-level scheduling. Scheduling the real-time run queue of each container control group can ensure that each real-time container is scheduled for execution. The second level uses a fixed priority scheduling policy to schedule tasks within the container. Tasks running within the control group will only be scheduled when the deadline entity of the control group has been scheduled by SCHED_DEADLINE. For non-real-time containers, the system will dynamically adjust the CPU capacity allocated to each non-real-time container through the dynamic adjustment module during runtime; at the same time, in order to adapt to the variable workload of non-real-time containers, the performance monitoring module is used to collect the CPU usage of non-real-time containers every 1 second, and the dynamic adjustment module determines how to adjust the CPU allocation based on this information.
[0006] Although the hierarchical scheduling strategy adopted by the real-time container can ensure that each container control group can be completed before the DEADLINE, it cannot guarantee the minimum response time of each real-time task. The reasons are as follows: the first level uses the SCHED_DEADLINE scheduling strategy, so the control group with the shortest deadline will be served first, but from the perspective of the entire system, the high-priority real-time task does not necessarily have the shortest deadline, nor is it necessarily in the control group with the shortest deadline. This may cause the problem of high-priority real-time tasks not responding in a timely manner. Summary of the invention
[0007] Aiming at the problem that the existing hierarchical scheduling strategy for real-time containers cannot guarantee the minimum response time of real-time tasks, a hybrid scheduling method based on containerized mixed-criticality systems is proposed.
[0008] The technical solution of the present invention is:
[0009] A hybrid scheduling method based on containerized hybrid critical systems, wherein critical tasks running in real-time containers use a two-level real-time scheduling algorithm based on cycles and time slices, and non-critical tasks running in non-real-time containers use an embedded general scheduling algorithm, specifically including the following steps:
[0010] Step 1: Get the actual required scheduling blueprint, configure the first-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint in the containerized hybrid critical system, and establish the main time frame and container time frame: set the time of the main time frame, and set the execution order and execution time of each real-time container in each main time frame;
[0011] Step 2: Configure the second-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint: according to the different criticality of each task in each real-time container, set the scheduling order and execution time of each real-time task in the corresponding time frame of the container;
[0012] Step 3: Configure the number of time slices that each non-real-time task can occupy after being scheduled in the scheduling blueprint;
[0013] Step 4: Create and start a container, and the system runs according to the scheduling blueprint;
[0014] Step 5: During the system operation, if a real-time container is paused or exited, the system automatically adjusts the execution order and execution time of each real-time container in each main time frame;
[0015] Step 6: During the system operation, if a real-time task is suspended or exited, the system automatically adjusts the scheduling order and execution time of other real-time tasks in the container where the real-time task is located;
[0016] Step 7: During system operation, if a non-real-time container or a non-real-time task is paused or exited, the system automatically adjusts the scheduling execution sequence of the non-real-time task.
[0017] Furthermore, the scheduling based on the main time frame adopts a periodic fixed time slice scheduling strategy: the scheduling is carried out in a fixed and periodic manner, with a round-robin mechanism as the scheduling basis, by configuring the scheduled cycle and the duration within a cycle, and configuring the window scheduling within the main time frame at the same time, so as to realize the static setting of the scheduling order; in order to activate the round-robin, a main time frame is maintained with a fixed period, and the timed and repeated operation is realized through the framework; the main time frame allocates a container window, that is, the container time frame, to each container, and determines the offset and scheduled running time of the container window in the main time frame, and each container can only be executed at the specified time; in the process of time window configuration, the execution sequence of the container needs to be standardized.
[0018] Furthermore, the secondary real-time scheduling algorithm is based on the ARINC real-time scheduling algorithm and is further extended under the main time frame to target the multi-tasking characteristics of real-time containers. Specifically, under the single main time frame of the current real-time scheduling algorithm, time slices will be first allocated to each container rather than the task threads in the container, thereby forming a container time frame for each real-time container. Each real-time container will further perform a second-level real-time scheduling control on each task when running within its own container time frame. This level of scheduling will allocate time slices according to the pre-configured task time frame for each task.
[0019] Furthermore, the hybrid scheduling strategy is based on the design of the main time frame and container time frame established in the first level of the two-level real-time scheduling algorithm, which completely isolates the real-time container scheduling from the non-real-time container scheduling in terms of time slices, and ensures the preemptive scheduling of non-critical tasks by critical tasks. Specifically, within the main time frame of the two-level real-time scheduling algorithm, the scheduling will be divided into two stages: the real-time processing environment scheduling stage and the non-real-time processing environment scheduling stage. The real-time processing environment scheduling stage adopts the two-level real-time scheduling algorithm, and each real-time container obtains a fixed number of time slices in a main time frame and allocates them to the critical tasks in the container. In the non-real-time processing environment scheduling stage, a priority-based non-preemptive scheduling algorithm is adopted, that is, the tasks in the container with the highest priority in the non-real-time processing environment are selected for scheduling and execution. The number of time slices that each ordinary task can occupy after being scheduled in this stage can be configured. In order to ensure the determinism and stability of the main time frame, if the remaining time slices of a single main time frame are consumed, the non-real-time scheduling stage ends immediately, and the general scheduling strategy is continued after the non-real-time processing environment scheduling stage of the next main time frame begins.
[0020] Furthermore, when the remaining time slice of a single processor core cannot meet the needs of the next real-time container to be run, it will be bundled and run on a new processor core. This scheduling algorithm supports multi-core scenarios and unifies the length and allocation of time slices on each physical core running real-time scheduling.
[0021] Furthermore, this method binds a processor core to each real-time container by default.
[0022] Furthermore, in step 2, the criticality of each task includes the priority, the demand for resources, and the execution time factor.
[0023] The beneficial effects of the present invention are:
[0024] The secondary real-time scheduling algorithm for real-time containers proposed by the present invention, the design of the main time frame and container time frame established in the first level, completely isolates the real-time container scheduling from the non-real-time container scheduling from the time slice, guarantees the preemptive scheduling of critical tasks to non-critical tasks, and in each main time frame, the scheduling of non-real-time tasks can only be started after all real-time tasks have executed their corresponding number of time slices. Moreover, when configuring the execution order and execution time of each real-time container in the first-level main time frame, all real-time tasks in all real-time containers can be comprehensively considered, and according to their criticality, priority, demand for resources, execution time and other factors, a reasonable container execution sequence and a reasonable task execution sequence in each container are set to ensure that the response of the real-time task can be more timely. Parameters such as the main time frame, the container time frame, the execution order and execution time of each task can be configured in advance in the scheduling blueprint, and can also be dynamically adjusted according to actual conditions during the operation of the system.
[0025] Since different critical tasks may have different real-time scheduling requirements, this project method provides more flexible options for container scheduling within the first-level main time frame and task scheduling within the second-level container time frame. In the first-level main time frame, the scheduling blueprint can only set the required time slice ratio for each real-time container without configuring the execution order of the real-time containers. With this configuration, a real-time container may be scheduled multiple times within a main time frame, but the total execution time it can obtain is strictly configured according to the administrator's ratio. In the second-level container time frame, the administrator can configure different scheduling algorithms for each real-time container through the scheduling blueprint. This meets the actual needs of different types of critical tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a hybrid scheduling strategy diagram of critical and non-critical applications of the present invention;
[0027] Figure 2 It is a two-stage diagram of the hybrid scheduling algorithm of the present invention;
[0028] Figure 3 This is the time slice allocation diagram for the secondary real-time scheduling of the present invention. DETAILED DESCRIPTION
[0029] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0030] In a containerized mixed-criticality system, in order to reasonably allocate CPUs for real-time containers and non-real-time containers, it is necessary to ensure the determinism and real-time nature of real-time tasks in real-time containers, and to ensure that non-real-time containers can be responded to within a limited time without starvation, and to minimize task response delays, especially minimizing real-time task response delays. This invention proposes a hybrid real-time scheduling method. Figure 1 As shown, the critical tasks running in the real-time container use a two-level real-time scheduling algorithm based on cycles and time slices, and the non-critical tasks running in the non-real-time container use an embedded general scheduling algorithm.
[0031] Scheduling based on the major frame adopts a periodic fixed time slice scheduling strategy: scheduling is performed in a fixed and periodic manner, with a round-robin mechanism as the scheduling basis. By configuring the scheduled cycle and the duration within a cycle, and configuring the window scheduling within the major time frame, a static scheduling order can be achieved. In order to activate round-robin, a major time frame is maintained with a fixed period, and the framework is used to achieve timed and repeated operation; the major time frame allocates a container window (also called a container time frame, Containerframe) to each container, and determines the offset and scheduled running time of the container window in the major time frame. Each container can only be executed at the specified time and cannot be executed across boundaries to avoid affecting the operation of other containers. In the process of time window configuration, the execution sequence of the container needs to be standardized.
[0032] The secondary real-time scheduling algorithm of this solution is based on the ARINC real-time scheduling algorithm and is further extended under the main time frame to target the multi-tasking characteristics of real-time containers. Specifically, under the single main time frame of the current real-time scheduling algorithm, time slices are first allocated to each container rather than the task threads in the container, thereby forming a container time frame for each real-time container. When each real-time container runs within its own container time frame, it will further perform a second-level real-time scheduling control on each task. This level of scheduling will allocate time slices according to the pre-configured task time frame (Taskframe) of each task.
[0033] The hybrid scheduling strategy is based on the design of the main time frame and container time frame established by the first level of the two-level real-time scheduling algorithm. It completely isolates the real-time container scheduling from the non-real-time container scheduling in terms of time slices, ensuring the preemptive scheduling of critical tasks over non-critical tasks. Specifically, within the main time frame of the two-level real-time scheduling algorithm, scheduling will be divided into two stages: the real-time processing environment scheduling stage and the non-real-time processing environment scheduling stage, such as Figure 2 As shown. The real-time processing environment scheduling stage adopts a two-level real-time scheduling algorithm. Each real-time container obtains a fixed number of time slices within a main time frame and allocates them to the key tasks in the container, thereby ensuring that both the real-time container and the key tasks can run within a foreseeable time slice. In the non-real-time processing environment scheduling stage, a priority-based non-preemptive scheduling algorithm is adopted, that is, the task in the container with the highest priority in the non-real-time processing environment is selected for scheduling and execution. The number of time slices that each ordinary task can occupy after being scheduled in this stage can be configured. In order to ensure the certainty and stability of the main time frame, if the remaining time slices of a single main time frame are consumed, the non-real-time scheduling stage ends immediately, and the general scheduling strategy will continue after the non-real-time processing environment scheduling stage of the next main time frame begins.
[0034] This scheduling algorithm also supports multi-core scenarios, which unifies the length and allocation of time slices on each physical core running real-time scheduling. Container tasks cannot repeatedly occupy excessive time slices by switching physical cores within the same main time frame, nor will they lose time slice occupancy due to switching physical cores. Since switching processor cores to execute tasks can cause unstable performance, this solution will bind a processor core to each real-time container by default. The multi-core capability of this algorithm is recommended only for bundling a single processor core to run on a new processor core when the remaining time slice of the next real-time container to be run cannot be satisfied, rather than multi-core switching after the real-time container is running.
[0035] The scheduling strategy of binding the processing core can make the internal environment of the scheduled processor more stable, reduce the failure of resources such as cache, and eliminate the overhead of synchronizing or transferring container task information on each core.
[0036] The specific steps of using the scheme of the present invention are as follows:
[0037] (1) Obtain the actual required scheduling blueprint, configure the first-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint in the containerized hybrid critical system, and establish the main time frame and container time frame: set the time of the main time frame, and set the execution order and execution time of each real-time container in each main time frame.
[0038] (2) Configure the second-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint: according to the different criticality, priority, resource requirements, execution time and other factors of each task in each real-time container, set the scheduling order and execution time of each real-time task in the container within the corresponding time frame.
[0039] (3) Configure the number of time slices that each non-real-time task can occupy after being scheduled in the scheduling blueprint.
[0040] (4) Create and start the container, and the system runs according to the scheduling blueprint.
[0041] (5) During system operation, if a real-time container is paused or exited, the system automatically adjusts the execution order and execution time of each real-time container in each main time frame.
[0042] (6) During system operation, if a real-time task is paused or exited, the system automatically adjusts the scheduling order and execution time of other real-time tasks in the container where the real-time task is located.
[0043] (7) During system operation, if a non-real-time container or non-real-time task is paused or exited, the system automatically adjusts the scheduling execution sequence of the non-real-time task.
[0044] For ease of understanding, the following example is given: Figure 3 As shown, the current blueprint configuration requires two real-time containers and several ordinary containers to run in the system, where real-time container 1 is a single-task container that requires 40 milliseconds of execution time in every 200 milliseconds, and real-time container 2 requires 30 milliseconds of execution time in every 100 milliseconds, of which 10 milliseconds are for task 1 and 20 milliseconds are for task 2. Therefore, this system will set the scheduler's time slice to 10 milliseconds, the main time frame to 10 time slices, and allocate the first two time slices of each main frame to container 1 as its container time frame, and allocate the next three time slices as the container time frame of real-time container 2. Since real-time container 2 contains two tasks, the scheduler further configures according to the blueprint, schedules task 1 when the first time slice in the container time frame arrives, and schedules task 2 when the next two time slices arrive. In this way, this scheduler can achieve real-time guarantee for real-time containers and their internal key tasks. The remaining time slices in the main time frame will be used by ordinary containers.
[0045] The above-mentioned embodiment only expresses one implementation mode of the present invention, and its description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.
Claims
1. A hybrid scheduling method based on containerized hybrid critical systems, characterized in that: The critical tasks running in the real-time container use a two-level real-time scheduling algorithm based on cycles and time slices, and the non-critical tasks running in the non-real-time container use an embedded general scheduling algorithm, which includes the following steps: Step 1: Get the actual required scheduling blueprint, configure the first-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint in the containerized hybrid critical system, and establish the main time frame and container time frame: set the time of the main time frame, and set the execution order and execution time of each real-time container in each main time frame; Step 2: Configure the second-level scheduling strategy in the second-level real-time scheduling in the scheduling blueprint: according to the different criticality of each task in each real-time container, set the scheduling order and execution time of each real-time task in the corresponding time frame of the container; Step 3: Configure the number of time slices that each non-real-time task can occupy after being scheduled in the scheduling blueprint; Step 4: Create and start a container, and the system runs according to the scheduling blueprint; Step 5: During the system operation, if a real-time container is paused or exited, the system automatically adjusts the execution order and execution time of each real-time container in each main time frame; Step 6: During the system operation, if a real-time task is suspended or exited, the system automatically adjusts the scheduling order and execution time of other real-time tasks in the container where the real-time task is located; Step 7: During system operation, if a non-real-time container or a non-real-time task is paused or exited, the system automatically adjusts the scheduling execution sequence of the non-real-time task.
2. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: Scheduling based on the main time frame adopts a periodic fixed time slice scheduling strategy: scheduling is carried out in a fixed and periodic manner, with a round-robin mechanism as the scheduling basis. By configuring the scheduled cycle and the duration within a cycle, and configuring the window scheduling within the main time frame, a static setting of the scheduling order is achieved; in order to activate the round-robin, a main time frame is maintained with a fixed period, and the framework is used to achieve timed and repeated operation; the main time frame allocates a container window, namely the container time frame, to each container, and determines the offset and scheduled running time of the container window in the main time frame. Each container can only be executed at the specified time; in the process of time window configuration, the execution sequence of the container needs to be standardized.
3. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: The secondary real-time scheduling algorithm is based on the ARINC real-time scheduling algorithm and is further expanded under the main time frame to target the multi-tasking characteristics of real-time containers. Specifically, under the single main time frame of the current real-time scheduling algorithm, time slices will be first allocated to each container rather than the task threads in the container, thereby forming a container time frame for each real-time container. When each real-time container runs within its own container time frame, it will further perform the second-level real-time scheduling control on each task. This level of scheduling will allocate time slices according to the pre-configured task time frame for each task.
4. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: The hybrid scheduling strategy is based on the design of the main time frame and container time frame established in the first level of the two-level real-time scheduling algorithm, which completely isolates the real-time container scheduling from the non-real-time container scheduling in terms of time slices, and ensures the preemptive scheduling of non-critical tasks by critical tasks. Specifically, within the main time frame of the two-level real-time scheduling algorithm, the scheduling will be divided into two stages: the real-time processing environment scheduling stage and the non-real-time processing environment scheduling stage. The real-time processing environment scheduling stage adopts the two-level real-time scheduling algorithm, and each real-time container obtains a fixed number of time slices in a main time frame and allocates them to the critical tasks in the container. In the non-real-time processing environment scheduling stage, a priority-based non-preemptive scheduling algorithm is adopted, that is, the tasks in the container with the highest priority in the non-real-time processing environment are selected for scheduling and execution. The number of time slices that each ordinary task can occupy after being scheduled in this stage can be configured. In order to ensure the determinism and stability of the main time frame, if the remaining time slices of a single main time frame are consumed, the non-real-time scheduling stage ends immediately, and the general scheduling strategy is continued after the non-real-time processing environment scheduling stage of the next main time frame begins.
5. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: When the remaining time slice of a single processor core cannot meet the needs of the next real-time container to be run, it will be bundled and run on a new processor core. This scheduling algorithm supports multi-core scenarios and unifies the length and allocation of time slices on each physical core running real-time scheduling.
6. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: This method binds a processor core to each real-time container by default.
7. The hybrid scheduling method based on containerized hybrid critical system according to claim 1 is characterized in that: In step 2, the criticality of each task includes the priority, resource requirements, and execution time factors.
Citation Information
Patent Citations
Task scheduling apparatus and method for embedded operating system
CN101452404A
Hybrid task scheduling method and model for railway locomotive operation control system
CN106773711A
Real-time task scheduling method and module for non-real-time operating system, terminal and storage medium
CN112579271A
Dual-operating system hybrid real-time task scheduling method and system based on trusted area
CN115269139A
Scheduling method and system for AOE network computing tasks in Linux system
CN117453379A
Cited By
Hybrid scheduling method based on containerized mixed-criticality system
WO2026137766A1