Embedded system resource allocation method and system based on hardware virtualization
By using a hardware virtualization-based embedded system resource allocation method, domain partitioning is created and computing resources are dynamically allocated. This solves the resource allocation and scheduling problem when real-time and non-real-time tasks coexist in traditional embedded systems, achieving high responsiveness for real-time tasks and high throughput for non-real-time tasks, thereby improving system performance and reliability.
Patent Information
- Application Number
- CN202511181082.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-22
- Publication Date
- 2025-12-09
AI Technical Summary
Traditional embedded systems struggle to simultaneously meet the high responsiveness requirements of real-time tasks and the high throughput demands of non-real-time tasks. Existing virtualization technologies suffer from high task switching overhead and low resource utilization in scenarios with high real-time requirements.
An embedded system resource allocation method based on hardware virtualization is adopted. The hardware platform is virtualized through the Type-1 virtual machine monitor, creating zone G and zone R, where a general-purpose operating system and a real-time operating system are deployed respectively. The combined scheduling analysis method is used to dynamically allocate computing resources. The real-time operating system executes real-time tasks according to the optimal cycle, while the general-purpose operating system executes non-real-time tasks through the time-slice polling method. Inter-core communication is realized by combining the OpenAMP protocol and the national cryptographic sm4 algorithm.
It improves the response speed of real-time tasks and the resource utilization of non-real-time tasks, enhances the overall performance and reliability of the system, and reduces task switching overhead.
Smart Images

Figure CN121092306A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of embedded system technology, specifically relating to an embedded system resource allocation method and system based on hardware virtualization. Background Technology
[0002] With the widespread application of embedded systems, especially in fields such as intelligent vehicles and industrial control, the need for coexistence of real-time and non-real-time tasks is increasing. Traditional embedded systems typically use a single operating system kernel, which makes it difficult to simultaneously meet the high responsiveness requirements of real-time tasks and the high throughput requirements of non-real-time tasks.
[0003] While existing virtualization technologies can achieve resource isolation and allocation, they still suffer from problems such as high task switching overhead and low resource utilization in scenarios with high real-time requirements.
[0004] Therefore, there is an urgent need for a new method for resource allocation in embedded systems to improve the efficiency of resource allocation and scheduling. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a resource allocation method for embedded systems based on hardware virtualization, aiming to solve the resource allocation and scheduling problem when real-time tasks and non-real-time tasks coexist in embedded systems, thereby improving the overall performance and reliability of the system.
[0006] Technical solution:
[0007] This invention proposes a resource allocation method for embedded systems based on hardware virtualization, comprising:
[0008] A Type-1 virtual machine monitor deployed on a hardware platform virtualizes the physical resources of the hardware platform to obtain a virtual CPU; the virtual CPU includes domain partitions zoneG and zoneR of the operating system execution environment, in which a general-purpose operating system for undertaking non-real-time tasks is deployed in zoneG, and a real-time operating system for undertaking real-time tasks is deployed in zoneR.
[0009] Real-time tasks are modeled using a combined scheduling analysis method to calculate the optimal execution period and scheduler time slice for real-time tasks.
[0010] The scheduler of the Type-1 virtual machine monitor dynamically allocates computing resources between the general-purpose operating system and the real-time operating system according to the scheduler's time slice; the real-time operating system executes real-time tasks according to the optimal cycle, and the general-purpose operating system shares the idle computing resources of the real-time operating system to execute non-real-time tasks through a time-slice polling method.
[0011] Furthermore, the hardware platform is a multi-core processor that supports virtualization expansion, and the Type-1 virtual machine monitor uses decoupling kernel technology to run directly on the hardware platform.
[0012] Furthermore, the virtualization involves virtualizing the CPU, memory, and I / O devices of the hardware platform, including dividing physical CPU time slices into virtual CPUs.
[0013] Furthermore, the domain partitions zoneG and zoneR employ a memory isolation mechanism and operate independently in time and space. The general-purpose operating system prohibits cross-virtual machine out-of-bounds access.
[0014] Furthermore, the real-time operating system and the general-purpose operating system implement inter-core communication based on the OpenAMP protocol, and transmit data through shared memory and interrupt mechanisms; the inter-core communication uses the national cryptographic sm4 algorithm to encrypt the inter-core communication data.
[0015] Furthermore, the modeling of real-time tasks using the combined scheduling analysis method includes:
[0016] Define a task set Γ={τ1,τ2,…,τ} for n real-time tasks. i ,…,τ n}, each task τ i From the task cycle p i Execution time e i and deadline d i Triplet parameter representation; task period p i This represents the minimum time interval between two consecutive activations of a real-time task; execution time e i This represents the worst-case computation time required for a real-time task; the deadline d. i This represents the maximum time constraint from activation to completion of a real-time task, satisfying e. i ≤di≤p i ;
[0017] The task requirement boundary function dbf(t) is expressed as:
[0018]
[0019] Let the VCPU cycle be ∏, the time slice be θ, and the resource supply boundary function sbf(t) be expressed as:
[0020]
[0021] When dbf(t)≤sbf(t), the system real-time requirements are met. By traversing the arrays, we can obtain the (∏,θ) combinations that satisfy the minimum VCPU bandwidth B:
[0022]
[0023] in, VCPU task switching overhead time.
[0024] Furthermore, the dynamic allocation of computing resources between the general-purpose operating system and the real-time operating system includes:
[0025] The VCPU of the real-time operating system is assigned the highest priority to execute real-time tasks; the VCPU of the general-purpose operating system is assigned the second highest priority to schedule non-real-time tasks using a time-slice round-robin method.
[0026] Furthermore, the allocation of the highest priority includes:
[0027] The virtual machine monitor scheduler sets the optimal period and time slice for the VCPU of the real-time operating system. When the time slice is exhausted, the VCPU of the real-time operating system is moved into the waiting queue. When the optimal period arrives, it is ready again.
[0028] Furthermore, the time-slice polling method includes:
[0029] In the general operating system of zoneG, a multi-level ready queue is maintained, with each queue corresponding to a fixed priority; each non-real-time task is allocated an equal-length time slice, and tasks of the same priority are executed in a first-in-first-out (FIFO) order; after a task uses up its time slice, it is demoted to the next lower-priority queue, and the high-priority queue schedules the low-priority queue when it is idle; when a real-time task is ready, it immediately preempts the non-real-time task, and the preempted task retains its remaining time slice.
[0030] This invention also proposes a system resource allocation system based on hardware virtualization, comprising:
[0031] The partitioning module is used to virtualize the physical resources of the hardware platform through a Type-1 virtual machine monitor deployed on the hardware platform to obtain a virtual CPU; the virtual CPU includes domain partitions zoneG and zoneR for the operating system execution environment, in which a general-purpose operating system for non-real-time tasks is deployed in zoneG and a real-time operating system for real-time tasks is deployed in zoneR.
[0032] The analysis module is used to model real-time tasks through combined scheduling analysis methods, and to calculate the optimal execution period and scheduler time slice for real-time tasks.
[0033] The allocation module is used to dynamically allocate computing resources of the general-purpose operating system and the real-time operating system according to the scheduler time slice through the scheduler of the Type-1 virtual machine monitor; the real-time operating system executes real-time tasks according to the optimal cycle, and the general-purpose operating system shares the idle computing resources of the real-time operating system to execute non-real-time tasks through the time slice polling method.
[0034] Beneficial effects:
[0035] This invention utilizes hardware virtualization and dynamic resource management mechanisms to dynamically allocate hardware resources. Based on a two-layer scheduling strategy and inter-core communication mechanism, it enables efficient collaboration between the RTOS and GPOS, maximizing resource utilization for non-real-time tasks while ensuring timely completion of real-time tasks, thereby improving overall system performance and reliability. Through dynamic resource allocation and scheduling strategy optimization, this invention reduces task switching overhead and improves system response speed and throughput. Attached Figure Description
[0036] Figure 1 This is a flowchart of the method of the present invention;
[0037] Figure 2 This is a diagram of the hierarchical scheduling framework of the present invention. Detailed Implementation
[0038] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments. This embodiment provides a resource allocation method for an embedded system based on hardware virtualization, such as... Figure 1 As shown, it includes the following steps:
[0039] S1, Virtualization
[0040] Deploy the Type-1 virtual machine monitor system on a multi-core processor hardware platform that supports virtualization extensions. The Type-1 virtual machine monitor system is a lightweight micro-operating system that runs directly on the hardware using decoupling kernel technology, managing the underlying hardware downwards and various domain partitions upwards.
[0041] Based on the characteristics of the hardware platform, configure and compile the uboot and Type-1 virtual machine monitor system images, burn the uboot and Type-1 virtual machine monitor system images to the storage memory of the multi-core processor hardware platform, and start the Type-1 virtual machine monitor system.
[0042] Elastic allocation of hardware resources is achieved by deploying the Type-1 virtual machine monitor system on a multi-core processor hardware platform that supports virtualization extensions. As a lightweight micro-operating system, the Type-1 virtual machine monitor system runs directly on the hardware, adopts a split kernel technology, manages the underlying hardware downwards and manages various domain partitions upwards, and realizes flexible scheduling and efficient utilization of resources.
[0043] S2. Create partitions
[0044] The Type-1 virtual machine monitor system virtualizes and isolates hardware resources, creating operating system execution environment partitions zoneG and zoneR. The OpenAMP protocol is compiled and ported to the Type-1 virtual machine monitor system.
[0045] The virtualization of hardware resources involves virtualizing the CPU, memory, and I / O devices to ensure resource isolation between different tasks. Hardware-assisted virtualization technology reduces virtualization overhead and improves system performance. This resource isolation is achieved through a memory isolation mechanism, utilizing a memory management unit and page tables to virtualize and isolate memory. An independent memory page table is allocated to each domain partition. Hardware-provided memory access control mechanisms restrict domain partitions' access permissions to physical memory, and the operating system's memory protection mechanisms prevent out-of-bounds memory access. Cross-virtual machine out-of-bounds access is also prevented.
[0046] Zone0 is a dedicated partition for the Type-1 virtual machine monitor, hosting a lightweight embedded Linux operating system responsible for system management tasks. ZoneG handles high-performance computing tasks, with applications including Linux and unikernels. ZoneR handles real-time computing tasks, with applications including RTOS for MCUs and bare-metal applications. Each partition is strictly isolated in time and space, and the systems within each partition operate independently without interference.
[0047] S3, Deploy the operating system
[0048] A general-purpose operating system (GPOS) is deployed in zone G to handle high-performance computing tasks, while a real-time operating system (RTOS) is deployed in zone R to handle real-time computing tasks.
[0049] The general-purpose operating system embedded Linux image is deployed in the zoneG partition. The zoneG partition system is responsible for non-real-time tasks such as business data analysis, storage, and cloud synchronization. The real-time operating system rt-thread image is deployed in the zoneR partition. The zoneR partition system is responsible for high real-time tasks such as real-time acquisition, data conversion and transmission.
[0050] Based on hardware virtualization, this invention creates two operating system execution environment domain partitions, zoneG and zoneR, realizing the integration of RTOS and GPOS on the same hardware platform, and the mechanism of resource allocation and scheduling through the Type-1 virtual machine monitor system, which constitutes the resource allocation basis of this invention.
[0051] S4. Configure the communication method between the real-time operating system and the general-purpose operating system.
[0052] This system implements low-latency inter-core communication between a real-time operating system and a general-purpose operating system based on the OpenAMP protocol, using shared memory and interrupt mechanisms for data transmission. The inter-core communication data is encrypted using the national cryptographic algorithm SM4 to prevent malicious attacks.
[0053] RTOS and GPOS work efficiently together across different domain partitions via the OpenAMP protocol, enabling real-time data transmission and processing. The OpenAMP protocol utilizes shared memory and interrupt mechanisms for data transmission, improving the efficiency of inter-core communication.
[0054] The shared memory is a dedicated shared area in physical memory that the virtual machine monitor allocates during the startup phase based on hardware-assisted virtualization technology and maps to the address spaces of the general partition and the real-time partition.
[0055] The interrupt mechanism achieves efficient inter-core communication through hardware-level signal triggering and a hierarchical processing strategy. When the sender (RTOS) writes data to shared memory, it directly writes to the inter-processor interrupt register, triggering an interrupt in the target mailbox. The receiver responds hierarchically according to the operating system characteristics. Specifically, the hierarchical response includes: the RTOS side processes data in real-time with the highest priority to ensure critical tasks are not blocked; the GPOS side uses a hybrid NAPI mode (interrupt wake-up + batch polling), where the interrupt service routine wakes up the user-mode daemon to process data in batches, avoiding CPU overload caused by high-frequency interrupts. Simultaneously, after processing, the receiver sends back a doorbell interrupt to release the buffer lock, coordinating with memory barrier instructions to ensure data consistency, ultimately achieving microsecond-level communication and efficient resource collaboration in a secure and isolated environment.
[0056] S5. Allocate computing resources using the Type-1 Virtual Machine Monitor (VCPU) scheduler.
[0057] The Type-1 virtual machine monitor uses a two-layer scheduling framework, combining scheduling analysis methods to model real-time task sets, such as... Figure 2As shown, the underlying layer allocates physical CPU resources to virtual CPUs through the virtual machine monitor, with the real-time VCPUs in Zone R assigned the highest priority; the non-real-time VCPUs in Zone G are scheduled using time-slice round-robin scheduling, thus achieving system-level scheduling. The upper-layer RTOS domain allocates VCPU resources to real-time tasks using a real-time scheduling algorithm, while the GPOS domain uses a general scheduling policy to manage non-real-time tasks, thus achieving task-level scheduling. This architecture ensures that real-time tasks are not interfered with by non-real-time tasks through hierarchical isolation, while the resource allocation model provides schedulability guarantees for both levels of scheduling.
[0058] The Type-1 virtual machine monitor system VCPU scheduler allocates computing resources to the zoneG and zoneR partition systems, assigning the highest priority to the VCPUs of the zoneR partition RTOS to ensure that real-time tasks are executed first; and assigning the second-highest priority to the VCPUs of the zoneG partition GPOS, using time-slice round-robin scheduling for non-real-time tasks. The time-slice round-robin scheduling specifically includes:
[0059] a) Maintain a multi-level ready queue in the general operating system of zoneG partition, with each queue corresponding to a fixed priority;
[0060] b) Allocate an equal-length slice to each non-real-time task, and execute tasks of the same priority in a first-in-first-out (FIFO) order.
[0061] c) After a task uses up its time slice, it is moved to the next lower priority queue. When the high priority queue is idle, the low priority queue is scheduled.
[0062] d) When a real-time task is ready, a non-real-time task is immediately preempted, and the preempted task retains its remaining time slice.
[0063] S6. Modeling real-time tasks
[0064] The specific steps of the combined scheduling analysis method include:
[0065] (1) Periodically model the real-time task set and formally describe it using a periodic task model. Define the task set Γ={τ1,τ2,…,τ n}, where each task τ i From the task cycle p i Execution time e i and deadline d i Triple parameter characterization.
[0066] Task cycle p i Indicates the minimum time interval between two consecutive activations of a task; execution time e i This represents the worst-case computation time required for the task; the deadline d. iThis represents the longest time constraint from task activation to mandatory completion, satisfying e. i ≤ di ≤ p i .
[0067] (2) Calculate the optimal cycle and time slice of VCPU by defining the task demand boundary function (dbf) and the resource supply boundary function (sbf). The task demand boundary function (dbf) represents the maximum resource demand of the task set within the time window t.
[0068]
[0069] The resource supply boundary function (sbf) characterizes the minimum amount of resources that a VCPU can provide within a time window t. Let the VCPU period be ∏ and the time slice be θ, then the resource supply boundary function is defined as follows:
[0070]
[0071] When resource supply exceeds task demand, i.e., dbf(t) ≤ sbf(t), the system's real-time requirements are met. Optimize VCPU cycles and time slices. To account for VCPU task switching overhead, we obtain the ∏,θ combinations that satisfy the minimum VCPU bandwidth B through iteration. The expression for the minimum VCPU bandwidth is:
[0072]
[0073] S7. Implement dynamic resource allocation
[0074] On the virtual machine monitor scheduler, optimal periods and time slices are set for the VCPUs of the RTOS. When a time slice is exhausted, the VCPU is moved to a waiting queue, and it becomes ready again when the period expires. When the CPU of the real-time operating system periodically sleeps and releases physical CPU resources, the scheduler selects a general-purpose operating system CPU from the ready queue in a round-robin manner. Each CPU is allocated a fixed time slice to execute non-real-time tasks. Multiple general-purpose operating system CPUs fairly share the idle computing resources of the real-time operating system during its sleep phase through round-robin, thereby maximizing processor utilization while ensuring strict scheduling of real-time tasks.
Claims
1. A method for allocating resources of an embedded system based on hardware virtualization, characterized in that, The application relates to a method for scheduling a real-time task in a Type-1 virtual machine monitor (VMM) on a hardware platform. The Type-1 VMM virtualizes physical resources of the hardware platform to obtain virtual CPUs (VCPU); the VCPU includes zone G and zone R of an operating system execution environment; a general operating system for undertaking non-real-time tasks is deployed in the zone G, and a real-time operating system for undertaking real-time tasks is deployed in the zone R; The real-time task is modeled by a combined scheduling analysis method, and optimal period and scheduler time slice of the real-time task execution are calculated; A scheduler of the Type-1 VMM dynamically allocates computing resources of the general operating system and the real-time operating system according to the scheduler time slice; the real-time operating system executes the real-time task according to the optimal period, and the general operating system shares idle computing resources of the real-time operating system by a time slice polling method to execute the non-real-time task.
2. The method of claim 1, wherein, The hardware platform is a multi-core processor supporting virtualization extension, and the Type-1 VMM runs on the hardware platform by using a split kernel technology.
3. The method of claim 2, wherein, The virtualization is performed on CPUs, memories and I / O devices of the hardware platform, and includes time slice division of physical CPUs into virtual CPUs.
4. The method of claim 3, wherein, The zone G and the zone R independently run in time and space by using a memory isolation mechanism, and cross-border access of the general operating system and the real-time operating system is prohibited.
5. The method of claim 4, wherein, The real-time operating system and the general operating system realize inter-core communication based on an OpenAMP protocol, and perform data transmission by a shared memory and an interrupt mechanism; the inter-core communication uses a national secret sm4 algorithm to encrypt inter-core communication data.
6. The method of claim 5, wherein, The modeling of the real-time task by the combined scheduling analysis method includes: Definition of a task set Γ = {τ1, τ2, …, τn} of n real-time tasks, each task τi characterized by a triple of parameters (pi, ei, di), where pi is the task period, ei is the execution time, and di is the deadline. i n i i i i i i i i i A task demand boundary function dbf (t) is expressed as: Supposing that a VCPU period is Pi and a time slice is theta, a resource supply boundary function sbf (t) is expressed as: When dbf (t) is less than sbf (t), the system real-time requirement is met, and (Pi, theta) combination meeting minimum VCPU bandwidth B is obtained by traversal: wherein, is the VCPU task switch overhead time.
7. The method of claim 6, wherein, The dynamic allocation of the computing resources of the general operating system and the real-time operating system includes: the VCPU of the real-time operating system is allocated with the highest priority, and the VCPU of the general operating system is allocated with a sub-optimal priority.
8. The method of claim 7, wherein, The allocation of the highest priority includes: the VCPU of the real-time operating system is set with an optimal period and a time slice on a scheduler of the Type-1 VMM, the VCPU of the real-time operating system is moved into a waiting queue when the time slice is exhausted, and the VCPU of the real-time operating system is re-ready when the optimal period arrives.
9. The method of claim 8, wherein, The time slice polling method includes: A multi-level ready queue is maintained in the general operating system of the zone G, each queue corresponds to a fixed priority, each non-real-time task is allocated with an equal-length time slice, tasks of the same priority are executed in a first-in-first-out order, a task is lowered into a lower-priority queue of a next level when the task uses up the time slice, a high-priority queue is scheduled with a low-priority queue when the high-priority queue is empty, a real-time task immediately preempts a non-real-time task, and the non-real-time task retains a remaining time slice after being preempted.
10. A hardware virtualization based embedded system resource allocation system, characterized in that, The application further relates to a Type-1 VMM scheduling system. A partition module is configured to virtualize physical resources of a hardware platform by a Type-1 virtual machine monitor deployed on the hardware platform to obtain virtual CPUs; the virtual CPUs include domain partitions zoneG and zoneR of an operating system execution environment, a general operating system for undertaking non-real-time tasks is deployed in the zoneG, and a real-time operating system for undertaking real-time tasks is deployed in the zoneR; An analysis module is configured to model real-time tasks by a combined scheduling analysis method, and calculate an optimal period and a scheduler time slice of real-time task execution; An allocation module is configured to dynamically allocate computing resources of the general operating system and the real-time operating system according to the scheduler time slice by a scheduler of the Type-1 virtual machine monitor; the real-time operating system executes real-time tasks according to the optimal period, and the general operating system shares idle computing resources of the real-time operating system by a time slice polling method to execute non-real-time tasks.
Citation Information
Cited By
Dual-runtime engine collaboration method and system for industrial edge computing terminal
CN121919013A
Dual runtime engine coordination method and system for industrial edge computing terminals
CN121919013B