Multi-core real-time simulation method based on Xenomai
Through the multi-credit real-time simulation method based on Xenomai, the problems of insufficient simulation time, low computing efficiency, resource utilization conflicts, and limitations in the prior art are solved, and efficient and accurate real-time simulation performance is achieved, and good compatibility and scalability are provided.
Patent Information
- Application Number
- CN202510388121.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-06-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The prior art has problems such as insufficient simulation timeliness, low computing efficiency, resource utilization conflicts, and compatibility and scalability limitations in real-time simulation.
The multi-credit real-time simulation method based on Xenomai is adopted to achieve efficient and accurate real-time simulation through the steps of system environment construction, task division and allocation, design of real-time scheduling strategies, simulation model development, and performance detection and optimization.
It greatly improves real-time simulation performance, shortens simulation time, enhances system stability and reliability, improves resource utilization, reduces energy consumption, and has good compatibility and scalability.
Smart Images

Figure CN120179362A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of real-time simulation technology, and particularly to a multi-core real-time simulation method based on Xenomai. Background Art
[0002] The existing technologies closest to the present invention mainly include single-core real-time simulation methods, multi-core simulation methods based on traditional operating systems, and multi-core real-time simulation methods based on other real-time patches.
[0003] The single-core real-time simulation method means running a real-time simulation system on a single-core processor. Through the scheduling algorithms of real-time operating systems (such as RT-Linux, VxWorks, etc.), time slices are allocated and priority scheduling is performed on simulation tasks to ensure that critical tasks are completed within the specified time. The multi-core simulation method based on traditional operating systems means using the multi-thread or multi-process mechanism of traditional general-purpose operating systems (such as Windows, Linux, etc.) to achieve parallel computing on multi-core processors. Different simulation tasks are assigned to different cores for execution through the operating system scheduler to improve the simulation speed. The multi-core real-time simulation method based on other real-time patches mainly uses real-time patches such as PREEMPT_RT, in addition to Xenomai, which can be used to provide real-time capabilities for the Linux operating system. These methods also utilize the resources of multi-core processors and manage simulation tasks through real-time scheduling algorithms.
[0004] The simulation method based on a single-core real-time operating system mainly involves a single-core processor, and its computing power is limited, making it difficult to meet the real-time simulation requirements of complex systems. As the complexity of the simulation model continues to increase, the computing speed of the single-core system will become a bottleneck, resulting in the inability to complete simulation tasks on time and affecting real-time performance. At the same time, the single-core system can only execute simulation tasks sequentially and cannot effectively utilize the parallel computing of multi-core processors.
[0005] The traditional general-purpose operating systems involved in the multi-core simulation method based on traditional multi-core general-purpose operating systems are mainly oriented to general computing, and their scheduling algorithms and kernel structures cannot provide hard real-time guarantees. In a multi-core environment, due to operating system scheduling overhead and uncertainty, the response time of simulation tasks will be unstable, unable to meet the requirements of real-time simulation for time accuracy. At the same time, during multi-thread or multi-process parallel computing, different simulation tasks will compete for system resources (such as CPU, memory, I / O, etc.), leading to resource conflicts and performance degradation. For example, when multiple tasks access shared memory simultaneously, data inconsistency problems may occur.
[0006] The PREEMPT_RT patch involved in the multi-core real-time simulation method based on other real-time patches may have imperfect support for specific hardware platforms or software environments in some aspects, resulting in compatibility problems in actual applications. Summary of the Invention
[0007] The Xenomai-based multi-core real-time simulation method of the present invention aims to utilize the advantages of Xenomai real-time patches and multi-core processors to achieve efficient and accurate real-time simulation. The main technical problems solved by this simulation method are the insufficient real-time performance, low computing efficiency, resource utilization conflicts, and limitations in compatibility and scalability of traditional methods. The present invention provides a Xenomai-based multi-core real-time simulation method, which can effectively solve the problems raised in the above background technology. To solve the above problems, the technical solution adopted by the present invention is: a Xenomai-based multi-core real-time simulation method, characterized by including the following steps: S1. System environment setup: including downloading the Xenomai source code and the Linux kernel source code, as well as kernel configuration and multi-core system configuration; S2. Task division and allocation: including determining task parameters, dividing tasks into multiple subtasks, and allocating the divided subtasks to different CPU cores for execution; S3. Design of real-time scheduling strategy: including priority scheduling and task synchronization and communication; S4. Development of simulation model: including model establishment, optimization, and integration; S5. Performance detection and optimization: including monitoring the real-time performance indicators of the system, and optimizing and adjusting task allocation, scheduling strategy, and simulation model according to the performance monitoring results.
[0008] Preferably, in step S1, after the source code download is completed, apply the Xenomai patch to the Linux kernel source code; when configuring the kernel, enable the multi-core scheduling and real-time scheduler options.
[0009] Preferably, in step S2, the task parameters include function, execution time, period, and priority; divide subtasks according to the characteristics of the tasks and the architecture of the multi-core processor; use the API functions provided by Xenomai to allocate tasks.
[0010] Preferably, in step S3, the priority scheduling refers to assigning priorities to each task, and the algorithms used for priority scheduling include FIFO and RR; task synchronization and communication refer to realizing data exchange and synchronization of tasks on different cores.
[0011] Preferably, in step S4, a simulation model is established using MATLAB / Simulink, the simulation model is converted into C / C++ code, and run in a Xenomai-based system; the simulation model is optimized to reduce computational complexity and memory occupancy; the API functions provided by Xenomai are used to integrate the developed simulation model with the Xenomai real-time environment.
[0012] Preferably, in step S5, the tools for monitoring performance metrics include xeno-monitor and perf, and the performance metrics include task response time, CPU utilization, and memory usage.
[0013] Compared with the prior art, the present invention provides a multi-core real-time simulation method based on Xenomai, having the following beneficial effects: The present invention greatly improves the real-time simulation performance and shortens the simulation time; enhances the system stability and reliability and avoids data conflicts; improves the resource utilization rate and reduces energy consumption; also has good compatibility and scalability, can integrate new model algorithms, and adapts to diverse simulation requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 It is a flowchart of the simulation method of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0015] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments.
[0016] TERMINOLOGY EXPLANATION: Xenomai: An open-source real-time development framework, which is called 'a strong real-time extension of the Linux kernel' according to its function and works in coordination with the kernel to provide extensive, interface-independent hard real-time computing support for user-space applications; Linux: An open-source operating system; FIFO: (First in, First out) A real-time scheduling algorithm. Under the FIFO scheduling policy, tasks are executed in the order they arrive at the system; RR: (Round Robin) Round-robin scheduling algorithm, abbreviated as RR algorithm. A fixed time slice (time quantum) is allocated to each task, and tasks are executed in sequence. When the time slice of a task is used up, it is suspended and placed at the end of the queue, waiting for the next scheduling, and then the next task is executed; API function: (Application Programming Interface) is a set of predefined functions, protocols, and tools; MATLAB: (MATrix LABoratory) commercial mathematical software; Simulink: Visual simulation software in Simulation and Link matlab; xeno - monitor: (xenomai monitor) A performance monitoring tool provided by the Xenomai real - time framework for monitoring the performance of real - time systems built on Xenomai; Perf: (Performance counter hardware events) Performance counter hardware event tool.
[0017] As a specific embodiment of the present invention: Refer to Figure 1 , the present invention provides a multi - core real - time simulation method based on Xenomai, including the following steps: Step 1, system environment setup and multi - core system configuration 1. System environment setup: First, it is necessary to download the Xenomai source code and the corresponding Linux kernel source code from the official channels. After the download is completed, apply the Xenomai patch to the Linux kernel source code; next, perform kernel configuration. In the configuration interface, relevant options such as multi - core scheduling and real - time scheduler need to be enabled. Find the "Processor type and features" option and ensure that multi - core processor support is enabled; in the "Real - Time Subsystem", select an appropriate real - time scheduling algorithm (such as FIFO or RR). After the configuration is completed, save and exit; finally, compile and install the kernel.
[0018] 2. Multi - core system configuration: Enter the system's BIOS setup interface to ensure that the multi - core processor function is enabled. If the number of CPU cores displayed in the output is consistent with the actual hardware, it means that the multi - core processor has been correctly identified and managed.
[0019] Step 2, task division and allocation First, conduct a detailed analysis of the tasks in the real - time simulation system to determine parameters such as the function, execution time, period, and priority of each task. Then, according to the characteristics of the tasks and the architecture of the multi - core processor, divide the tasks into multiple subtasks. Finally, use the API functions provided by Xenomai to allocate the divided subtasks to different CPU cores for execution.
[0020] Step 3, real - time scheduling strategy 1. Priority Scheduling: In a multi-core system, it is necessary to consider the priority relationships of tasks on different cores to avoid issues such as priority inversion. This method uses Xenomai's priority scheduling algorithms (such as FIFO or RR) to implement task scheduling.
[0021] 2. Task Synchronization and Communication: Utilize various synchronization mechanisms provided by Xenomai, such as semaphores, mutexes, message queues, etc., to achieve data exchange and synchronization of tasks on different cores.
[0022] Step Four, Simulation Model Development 1. Model Establishment: According to the requirements of the simulation system, use appropriate modeling tools and programming languages to establish a simulation model. Use MATLAB / Simulink to establish the model and then convert it into C / C++ code to run on a Xenomai-based system.
[0023] 2. Model Optimization: Optimize the established simulation model to reduce computational complexity and memory occupancy and improve the running efficiency of the model.
[0024] 3. Model Integration: Use the API functions provided by Xenomai to integrate the developed simulation model with the Xenomai real-time environment to implement operations such as initialization, running, and termination of the model.
[0025] Step Five, Performance Detection and Optimization Use the performance monitoring tools provided by Xenomai (such as xeno-monitor) and the system's built-in monitoring tools (such as perf) to monitor the real-time performance metrics of the system, such as task response time, CPU utilization, memory usage, etc. Then, based on the performance monitoring results, optimize and adjust task allocation, scheduling strategies, simulation models, etc.
[0026] The multi-core real-time simulation method of the present invention based on Xenomai makes full use of the parallel computing power of multi-core processors, reasonably distributes different simulation tasks to multiple cores for parallel execution, greatly improves the computing speed, and can easily handle the real-time simulation of complex systems. At the same time, through Xenomai's real-time scheduling mechanism, it can efficiently manage and schedule multi-core resources, realize the parallel processing of multiple simulation tasks, and significantly improve the simulation efficiency.
[0027] The present invention adopts the Xenomai real-time patch, which is specifically designed for real-time applications, can provide hard real-time performance, ensure that simulation tasks are completed within strict time constraints, and effectively solve the real-time problem. Xenomai also provides synchronization mechanisms (such as semaphores, mutexes, etc.), which can effectively coordinate the resource access of tasks on different cores, avoid resource competition, and ensure the stability and reliability of the system.
[0028] Xenomai on which the invention is based has undergone long-term development and extensive application, has good hardware compatibility and rich functions, can adapt to a variety of different hardware platforms and software environments, and reduces the troubles in terms of compatibility.
[0029] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A multi-core real-time simulation method based on Xenomai, characterized in that: The following steps are involved: S1. System environment construction: including downloading Xenomai source code and Linux kernel source code, as well as kernel configuration and configuration of multi-core system; S2, task division and allocation: including determining task parameters, dividing the task into multiple subtasks, and allocating the divided subtasks to different CPU cores for execution; S3. Design real-time scheduling strategies: including priority scheduling and task synchronization and communication; S4. Simulation model development: including model establishment, optimization and integration; S5. Performance monitoring and optimization: including monitoring the real-time performance indicators of the system, and optimizing and adjusting task allocation, scheduling strategies and simulation models based on the performance monitoring results.
2. A multi-core real-time simulation method based on Xenomai according to claim 1, characterized in that: In step S1, after the source code is downloaded, the Xenomai patch is applied to the Linux kernel source code; when configuring the kernel, the multi-core scheduling and real-time scheduler options are enabled.
3. A multi-core real-time simulation method based on Xenomai according to claim 1, characterized in that: In step S2, the task parameters include function, execution time, cycle and priority; subtasks are divided according to the characteristics of the task and the architecture of the multi-core processor; and tasks are assigned using the API function provided by Xenomai.
4. The multi-core real-time simulation method based on Xenomai according to claim 1, characterized in that: In step S3, the priority scheduling refers to assigning a priority to each task, and the algorithms used in the priority scheduling include FIFO and RR; task synchronization and communication refers to realizing data exchange and synchronization of tasks on different cores.
5. The multi-core real-time simulation method based on Xenomai according to claim 1, characterized in that: In the step S4, a simulation model is established using MATLAB / Simulink, and the simulation model is converted into C / C++ code and run in a system based on Xenomai; the simulation model is optimized to reduce computational complexity and memory usage; and the developed simulation model is integrated with the Xenomai real-time environment using the API function provided by Xenomai.
6. The multi-core real-time simulation method based on Xenomai according to claim 1, characterized in that: In step S5, the tools for monitoring performance indicators include xeno-monitor and perf, and the performance indicators include task response time, CPU utilization and memory usage.
Citation Information
Patent Citations
Method for realizing real-time control processing of numerical control system based on Xenomai real-time kernel
CN111061225A
Multi-core real-time task scheduling analysis and simulation system and method
CN114327829A
Multi-core parallel simulation method and platform architecture for realizing multi-core parallel simulation
CN114996077A
Hierarchical multi-core real-time scheduler
CN117724811A
Analog simulation calculation method based on multiple modules
CN119127483A