Process migration method and device of embedded system
By screening and identifying target CPU cores, only the incremental part of processes in embedded systems is migrated, solving the problems of efficiency and security in process migration on embedded platforms, and achieving high reliability and low latency migration in automotive electronic systems.
Patent Information
- Application Number
- CN202511720706.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-01-16
AI Technical Summary
Existing technologies struggle to achieve efficient, secure, and deterministic process migration on embedded platforms, particularly in automotive electronic systems where issues such as high state synchronization delays, unsafe migration processes, and heavy reliance on external connections exist.
By acquiring the real-time running status parameter values of the CPU cores in the embedded system and the preset process migration threshold, the CPU cores to be migrated are screened, and candidate CPU cores are selected within the same processor cluster. The target CPU core is determined, and current and historical process snapshots are obtained. Only the incremental part is migrated to achieve fast hot migration of processes.
It improves the reliability and efficiency of process migration, reduces the migration overhead of multi-core embedded systems, ensures that processes can migrate safely without interrupting services, and adapts to requirements such as load changes and processor overheating.
Smart Images

Figure CN121349634A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of software design and computer technology, and in particular to a process migration method and apparatus for an embedded system. Background Technology
[0002] With the development of intelligent vehicles, in-vehicle electronic systems (such as autonomous driving units, in-vehicle infotainment systems, and advanced driver assistance systems (ADAS)) are becoming increasingly complex. These systems are typically deployed on embedded multi-core platforms based on the ARM architecture. To improve system reliability and real-time performance, it is necessary to dynamically migrate certain running tasks without interrupting services to cope with load changes, processor overheating, software updates, or failover requirements.
[0003] Most existing technologies are based on server environments or PC platforms, making them difficult to apply in resource-constrained embedded platforms with high real-time requirements. Furthermore, traditional process migration methods suffer from drawbacks such as high state synchronization latency, insecure migration processes, and heavy reliance on external connections, which are unacceptable, especially in automotive electronic systems with extremely high security and deterministic requirements. Summary of the Invention
[0004] This application provides a process migration method and apparatus for embedded systems, which can improve the process migration efficiency in multi-core embedded systems.
[0005] On one hand, this application provides a process migration method for an embedded system, the embedded system including at least two CPU cores, the method comprising: Obtain the real-time running status parameter values corresponding to each of the at least two CPU cores and the preset process migration threshold; the preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate. Based on the real-time running status parameter values and the preset process migration threshold, at least two CPU cores are filtered to obtain the CPU cores to be migrated. From the at least two CPU cores, select the CPU cores that are in the same processor cluster as the CPU core to be migrated to obtain candidate CPU cores; The target CPU core is determined based on the real-time running status parameter values corresponding to the candidate CPU cores and the preset process migration threshold. Obtain the current process snapshot and the target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determine the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot; Send the target incremental snapshot to the target CPU core so that the current process in the CPU core to be migrated can be migrated to the target CPU core.
[0006] In one exemplary embodiment, the real-time running status parameter values include real-time CPU utilization and real-time CPU temperature values; the preset process migration threshold includes a preset CPU utilization threshold and a preset CPU temperature threshold. The step of filtering at least two CPU cores based on the real-time running status parameter values and the preset process migration threshold to obtain the CPU cores to be migrated includes: The real-time CPU utilization of each of the at least two CPU cores is compared with the preset CPU utilization threshold to obtain the CPU utilization comparison results of each of the at least two CPU cores. The real-time CPU temperature values corresponding to each of the at least two CPU cores are compared with the preset CPU temperature threshold to obtain the temperature comparison results corresponding to each of the at least two CPU cores. Based on the CPU utilization comparison results and temperature comparison results corresponding to at least two CPU cores, CPU cores with real-time CPU utilization greater than the preset CPU utilization threshold and real-time CPU temperature greater than the preset CPU temperature threshold are selected from the at least two CPU cores to obtain the CPU cores to be migrated.
[0007] In one exemplary embodiment, the real-time running status parameter value further includes the real-time CPU idle time; the preset process migration threshold further includes a preset CPU idle time threshold. The step of determining the target CPU core based on the real-time running status parameter values corresponding to the candidate CPU core and the preset process migration threshold includes: The real-time CPU idle time corresponding to the candidate CPU core is compared with the preset CPU idle time threshold to obtain the idle time comparison result; If the idle time comparison result indicates that the real-time CPU idle time corresponding to the candidate CPU core is greater than the preset CPU idle time threshold, the candidate CPU core is determined to be the target CPU core.
[0008] In one exemplary embodiment, obtaining a current process snapshot and a target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determining a target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot, includes: Obtain the current process control block, current memory mapping information, current file descriptor, current peripheral status information, current process identifier, and target CPU core identifier corresponding to the current process in the CPU core to be migrated; Based on the current process control block, current memory mapping information, current file descriptor, and current peripheral status information corresponding to the CPU core to be migrated, determine the current process snapshot corresponding to the CPU core to be migrated; The target CPU core snapshot relation is obtained by searching the CPU core snapshot relation library that matches the current process identifier in the preset process CPU core relation library; the preset process CPU core relation library includes the mapping relationship between preset process identifiers and preset CPU core snapshot relation libraries; the CPU core snapshot relation library includes the mapping relationship between preset CPU core identifiers and preset historical process snapshots. Search the target CPU core snapshot database for historical process snapshots that match the target CPU core identifier to obtain the target historical process snapshot; Based on the current process snapshot and the target historical process snapshot, determine the target incremental snapshot corresponding to the CPU core to be migrated.
[0009] In one exemplary implementation, determining the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot includes: Obtain historical memory mapping information, historical file descriptors, and historical peripheral status information from the target historical process snapshot; The current memory mapping information and the historical memory mapping information are compared to obtain a memory mapping information comparison result. The current file descriptor and the historical file descriptors are compared to obtain the file descriptor comparison result. The current peripheral status information and the historical peripheral status information are compared and processed to obtain the peripheral status information comparison result. Based on the comparison results of the memory mapping information, the file descriptor comparison results, and the peripheral status information, an initial incremental snapshot is determined. The target incremental snapshot is determined based on the current process control block and the initial incremental snapshot.
[0010] In one exemplary embodiment, the current memory mapping information includes at least two memory segment identifiers and memory segment information corresponding to each of the at least two memory segment identifiers; the historical memory mapping information includes at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers. The comparison process between the current memory mapping information and the historical memory mapping information to obtain the memory mapping information comparison result includes: Each memory segment identifier in the current memory mapping information is polled sequentially. For each polled current memory segment identifier, the existence of the current memory segment identifier is searched among the at least two historical memory segment identifiers to obtain the memory segment identifier search result. If the memory segment identifier lookup result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the memory segment identifier lookup result is used as the memory mapping information comparison result; If the memory segment identifier lookup result indicates that the current memory segment identifier exists among the at least two historical memory segment identifiers, the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are compared and processed to obtain the memory segment information comparison result; The comparison result of the memory segment information is used as the comparison result of the memory mapping information.
[0011] In one exemplary embodiment, determining the initial incremental snapshot based on the comparison results of the memory mapping information, the file descriptor comparison results, and the peripheral status information includes: Based on the comparison results of the memory mapping information, the current memory mapping information is filtered to obtain incremental memory mapping information; If the file descriptor comparison result indicates that the current file descriptor and the historical file descriptor are inconsistent, an incremental file descriptor is determined based on the current file descriptor and the historical file descriptor; If the comparison result of the peripheral status information indicates that the current peripheral status information and the historical peripheral status information are inconsistent, the incremental peripheral status information is determined based on the current peripheral status information and the historical peripheral status information. The initial incremental snapshot is determined based on the incremental memory mapping information, the incremental file descriptor, and the incremental peripheral status information.
[0012] In one exemplary embodiment, the step of filtering the current memory mapping information based on the comparison result of the memory mapping information to obtain incremental memory mapping information includes: If the memory mapping information comparison result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier are used as the first memory mapping information; If the memory mapping information comparison result indicates that the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are inconsistent, the current memory segment information shall be used as the second memory mapping information; The incremental memory mapping information is determined based on the first memory mapping information and the second memory mapping information.
[0013] In one exemplary embodiment, before sending the target incremental snapshot to the target CPU core, the method further includes: Send a memory allocation instruction to the target CPU core; so that the target CPU core allocates memory based on the memory allocation instruction to obtain the target memory space corresponding to the current process snapshot; Sending the target incremental snapshot to the target CPU core includes: Receive the memory allocation completion message sent by the target CPU core based on the memory allocation instruction; Based on the memory allocation completion message, the target incremental snapshot is sent to the target memory space in the target CPU core.
[0014] On the other hand, a process migration device for an embedded system is provided, the embedded system including at least two CPU cores, the device comprising: The first acquisition module is used to acquire the real-time running status parameter values corresponding to each of the at least two CPU cores and the preset process migration threshold; the preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate. The CPU core to be migrated determination module is used to filter at least two CPU cores based on the real-time running status parameter value and the preset process migration threshold to obtain the CPU cores to be migrated. The candidate CPU core determination module is used to filter CPU cores from the at least two CPU cores that are in the same processor cluster as the CPU core to be migrated, and obtain candidate CPU cores; The target CPU core determination module is used to determine the target CPU core based on the real-time running status parameter value corresponding to the candidate CPU core and the preset process migration threshold. The target incremental snapshot determination module is used to obtain the current process snapshot and the target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determine the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot. The migration module is used to send the target incremental snapshot to the target CPU core so that the current process in the CPU core to be migrated can be migrated to the target CPU core.
[0015] On the other hand, a process migration method for an embedded system is provided, characterized in that the embedded system includes at least two CPU cores, and the method includes: The real-time running status parameter values corresponding to each of the at least two CPU cores and the preset process migration threshold are obtained. The preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate. The real-time running status parameter values include real-time CPU utilization, real-time CPU temperature, and real-time CPU idle time. The preset process migration threshold includes a preset CPU utilization threshold, a preset CPU temperature threshold, and a preset CPU idle time threshold. The real-time CPU utilization of each of the at least two CPU cores is compared with the preset CPU utilization threshold to obtain the CPU utilization comparison results of each of the at least two CPU cores. The real-time CPU temperature values corresponding to each of the at least two CPU cores are compared with the preset CPU temperature threshold to obtain the temperature comparison results corresponding to each of the at least two CPU cores. Based on the CPU utilization comparison results and temperature comparison results corresponding to at least two CPU cores, CPU cores with real-time CPU utilization greater than the preset CPU utilization threshold and real-time CPU temperature greater than the preset CPU temperature threshold are selected from the at least two CPU cores to obtain the CPU cores to be migrated. From the at least two CPU cores, select the CPU cores that are in the same processor cluster as the CPU core to be migrated to obtain candidate CPU cores; The real-time CPU idle time corresponding to the candidate CPU core is compared with the preset CPU idle time threshold to obtain the idle time comparison result; If the idle time comparison result indicates that the real-time CPU idle time corresponding to the candidate CPU core is greater than the preset CPU idle time threshold, the candidate CPU core is determined to be the target CPU core. Obtain the current process control block, current memory mapping information, current file descriptor, current peripheral status information, current process identifier, and target CPU core identifier corresponding to the current process in the CPU core to be migrated; Based on the current process control block, current memory mapping information, current file descriptor, and current peripheral status information corresponding to the CPU core to be migrated, determine the current process snapshot corresponding to the CPU core to be migrated; the current memory mapping information includes at least two memory segment identifiers and the memory segment information corresponding to each of the at least two memory segment identifiers; The target CPU core snapshot relation is obtained by searching the CPU core snapshot relation library that matches the current process identifier in the preset process CPU core relation library; the preset process CPU core relation library includes the mapping relationship between preset process identifiers and preset CPU core snapshot relation libraries; the CPU core snapshot relation library includes the mapping relationship between preset CPU core identifiers and preset historical process snapshots. Search the target CPU core snapshot database for historical process snapshots that match the target CPU core identifier to obtain the target historical process snapshot; Obtain historical memory mapping information, historical file descriptors, and historical peripheral status information from the target historical process snapshot; the historical memory mapping information includes at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers. Each memory segment identifier in the current memory mapping information is polled sequentially. For each polled current memory segment identifier, the existence of the current memory segment identifier is searched among the at least two historical memory segment identifiers to obtain the memory segment identifier search result. If the memory segment identifier lookup result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the memory segment identifier lookup result is used as the memory mapping information comparison result; If the memory segment identifier lookup result indicates that the current memory segment identifier exists among the at least two historical memory segment identifiers, the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are compared and processed to obtain the memory segment information comparison result; The comparison result of the memory segment information is used as the comparison result of the memory mapping information; The current file descriptor and the historical file descriptors are compared to obtain the file descriptor comparison result. The current peripheral status information and the historical peripheral status information are compared and processed to obtain the peripheral status information comparison result. If the memory mapping information comparison result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier are used as the first memory mapping information; If the memory mapping information comparison result indicates that the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are inconsistent, the current memory segment information shall be used as the second memory mapping information; Incremental memory mapping information is determined based on the first memory mapping information and the second memory mapping information; If the file descriptor comparison result indicates that the current file descriptor and the historical file descriptor are inconsistent, an incremental file descriptor is determined based on the current file descriptor and the historical file descriptor; If the comparison result of the peripheral status information indicates that the current peripheral status information and the historical peripheral status information are inconsistent, the incremental peripheral status information is determined based on the current peripheral status information and the historical peripheral status information. The initial incremental snapshot is determined based on the incremental memory mapping information, the incremental file descriptor, and the incremental peripheral status information; The target incremental snapshot is determined based on the current process control block and the initial incremental snapshot; Send a memory allocation instruction to the target CPU core; so that the target CPU core allocates memory based on the memory allocation instruction to obtain the target memory space corresponding to the current process snapshot; Receive the memory allocation completion message sent by the target CPU core based on the memory allocation instruction; Based on the memory allocation completion message, the target incremental snapshot is sent to the target memory space in the target CPU core, so that the current process in the CPU core to be migrated can be migrated to the target CPU core.
[0016] On the other hand, an electronic device is provided, the device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded by the processor and executed as described above in the process migration method of the embedded system.
[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or at least one program being loaded and executed by a processor to implement the process migration method of the embedded system as described above.
[0018] On the other hand, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, executes the computer instructions, and causes the computer device to perform the process migration method of the embedded system as described above.
[0019] This application provides a process migration method and apparatus for an embedded system, which has the following technical effects: The application obtains real-time running status parameter values and a preset process migration threshold corresponding to each of the at least two CPU cores; the preset process migration threshold is the upper limit of the running status parameters required for the migration of processes within a CPU core; based on the real-time running status parameter values and the preset process migration threshold, the at least two CPU cores are screened to obtain CPU cores to be migrated; among the at least two CPU cores, CPU cores located in the same processor cluster as the CPU core to be migrated are selected to obtain candidate CPU cores; based on the real-time running status parameter values corresponding to the candidate CPU cores and the preset process migration threshold, a target CPU core is determined; a current process snapshot and a target historical process snapshot corresponding to the current process in the CPU core to be migrated are obtained, and a target incremental snapshot corresponding to the CPU core to be migrated is determined based on the current process snapshot and the target historical process snapshot; the target incremental snapshot is sent to the target CPU core; so that the current process in the CPU core to be migrated is migrated to the target CPU core. The system monitors the real-time running status parameters of at least two CPU cores in the embedded system and combines them with a preset process migration threshold. When the real-time running status parameter values exceed the preset process migration threshold, the system selects the CPU cores to be migrated, accurately locating the CPU cores to be migrated. It then selects CPU cores within the same processor cluster as the CPU core to be migrated, obtaining candidate CPU cores. Based on the real-time running status parameter values of the candidate CPU cores, the system determines the target CPU core, improving the reliability of process migration. Finally, based on the current process snapshot and the target's historical process snapshot, it determines the target incremental snapshot and migrates only the incremental portion, making the migration process lightweight, reducing the process migration overhead of multi-core embedded systems, and achieving fast hot migration of processes. Attached Figure Description
[0020] To more clearly illustrate the technical solutions and advantages in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating a process migration method for an embedded system provided in an embodiment of this specification. Figure 2 This is a flowchart illustrating a method for determining a CPU core to be migrated, as provided in an embodiment of this specification. Figure 3 This is a flowchart illustrating a method for determining a target incremental snapshot provided in an embodiment of this specification; Figure 4 This is a schematic diagram of a process migration device and process migration method for an embedded platform provided in the embodiments of this specification; Figure 5 This is a schematic diagram of the process migration device for an embedded system provided in the embodiments of this specification.
[0022] Figure 6 This is a schematic diagram of the server structure for an embedded system process migration method provided in the embodiments of this specification. Detailed Implementation
[0023] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0025] The following describes a process migration method for an embedded system according to this application. Figure 1 This is a flowchart illustrating a process migration method for an embedded system provided in an embodiment of this specification. This specification provides the operational steps of the method described in the embodiment or flowchart, but based on conventional or non-inventive methods, more or fewer operational steps may be included. The order of steps listed in the embodiment is merely one possible execution order among many and does not represent the only possible execution order. In actual system or server product execution, the method can be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment) as shown in the embodiment or accompanying drawings. Specifically, as... Figure 1 As shown, the method can be applied to an embedded system, which includes at least two CPU cores, and the method includes: S101: Obtain the real-time running status parameter values corresponding to each of the at least two CPU cores and the preset process migration threshold; the preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate.
[0026] In the embodiments of this specification, the embedded system is built on an embedded platform, that is, the embedded platform is the physical carrier of the embedded system. The embedded platform in the embodiments of this specification is a multi-core SOC based on the ARM architecture. A lightweight operating system, i.e., an embedded system (such as RTLinux, QNX or a customized embedded Linux), runs on this embedded platform. Here, ARM architecture refers to the fact that the central processing unit (CPU) core of the chip uses the instruction set and microarchitecture designed by ARM. Multi-core refers to the fact that multiple independent CPU computing cores (hereinafter referred to as CPU cores) are contained within the same chip. SOC refers to System on a Chip, which integrates the CPU, GPU, memory controller and various peripheral interface controllers into a single chip. To migrate a running process from one CPU core to another for load balancing, thermal management, or fault tolerance, it is necessary to continuously monitor the operating parameters of each CPU core in the embedded system to proactively prevent overheating and crashes. Therefore, it is necessary to obtain the real-time running status parameter values corresponding to at least two CPU cores and the preset process migration threshold. The preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate. That is, when the real-time running status parameter is greater than the preset process migration threshold, it indicates that the process within the CPU core needs to be migrated. Moreover, the preset process migration threshold can vary according to the characteristics of different CPU cores.
[0027] S103: Based on the real-time running status parameter value and the preset process migration threshold, the at least two CPU cores are screened to obtain the CPU cores to be migrated.
[0028] In the embodiments of this specification, the real-time running status parameter values include the real-time CPU utilization and real-time CPU temperature values corresponding to at least two CPU cores; wherein, the real-time CPU utilization is the total load of all tasks on the CPU core; the real-time CPU temperature value can be obtained by a temperature sensor inside the chip; the preset process migration threshold includes the preset CPU utilization threshold and the preset CPU temperature threshold corresponding to at least two CPU cores; the preset CPU utilization threshold is the upper limit of the total load of all tasks on the CPU core; the preset CPU temperature threshold is the upper limit of the CPU core temperature; The real-time running status parameter values and the preset process migration threshold are compared and processed. Based on the comparison results, at least two CPU cores are selected to obtain the CPU cores to be migrated.
[0029] In the embodiments of this specification, the real-time running status parameter values include real-time CPU utilization and real-time CPU temperature values; the preset process migration threshold includes a preset CPU utilization threshold and a preset CPU temperature threshold. The process involves filtering at least two CPU cores based on the real-time running status parameter values and the preset process migration threshold to obtain the CPU cores to be migrated. Figure 2 As shown, Figure 2 This is a flowchart illustrating a method for determining a CPU core to be migrated, as provided in an embodiment of this specification, including: S201: Compare the real-time CPU utilization of each of the at least two CPU cores with the preset CPU utilization threshold to obtain the CPU utilization comparison result of each of the at least two CPU cores.
[0030] In the embodiments of this specification, the preset CPU utilization threshold can be 85%; for each CPU core, the real-time CPU utilization corresponding to each CPU core is compared with the preset CPU utilization threshold to obtain the CPU utilization comparison results corresponding to at least two CPU cores.
[0031] S202: Compare the real-time CPU temperature values corresponding to each of the at least two CPU cores with the preset CPU temperature threshold to obtain the temperature comparison results corresponding to each of the at least two CPU cores.
[0032] In the embodiments of this specification, the preset CPU temperature threshold can be 80°C; for each CPU core, the real-time CPU temperature value corresponding to each CPU core is compared with the preset CPU temperature threshold to obtain the temperature comparison results corresponding to at least two CPU cores.
[0033] S203: Based on the CPU utilization comparison results and temperature comparison results corresponding to at least two CPU cores, select CPU cores from the at least two CPU cores whose real-time CPU utilization is greater than the preset CPU utilization threshold and whose real-time CPU temperature is greater than the preset CPU temperature threshold, and obtain the CPU cores to be migrated.
[0034] In the embodiments of this specification, based on the comparison results of CPU utilization and temperature of at least two CPU cores respectively, CPU cores with real-time CPU utilization greater than a preset CPU utilization threshold and real-time CPU temperature greater than a preset CPU temperature threshold are selected from at least two CPU cores. For example, CPU cores with real-time CPU utilization greater than 85% and real-time CPU temperature greater than 80°C are selected to obtain the CPU cores to be migrated.
[0035] Furthermore, after selecting the CPU cores to be migrated, a safety check can be performed on them to ensure that the current process on the CPU core is in a state that can be safely interrupted. For example, the CPU core to be migrated will not execute uninterruptible system calls, thereby ensuring the correctness of the process state after migration. By selecting the CPU cores to be migrated from at least two CPU cores based on the comparison results of their respective CPU utilization and temperature, dynamic adjustment based on the real-time workload and temperature changes of the CPU core is achieved. When the CPU core load is too high or overheats, process migration is actively performed, preventing system restarts or hardware damage caused by overheating and improving the reliability of the embedded system.
[0036] S105: Select CPU cores from the at least two CPU cores that are in the same processor cluster as the CPU core to be migrated to obtain candidate CPU cores.
[0037] In the embodiments of this specification, after the CPU core to be migrated is selected, the embedded system needs to find a suitable target node (CPU core) to receive the process in the CPU core to be migrated. Therefore, it is necessary to check the status of other CPU cores and select a CPU core that is sufficiently idle, so as to select candidate CPU cores from at least two CPU cores. In some embodiments, in a multi-core SoC based on the ARM architecture, CPUs are typically organized in a cluster. The same processor cluster shares L2 / L3 cache, has a unified memory view and consistency domain, and has the same microarchitecture and frequency domain and shares cluster-level power management. Therefore, in order to simplify the complexity of process migration and reduce memory access latency, CPU cores in the same processor cluster as the CPU core to be migrated can be selected from at least two CPU cores to obtain candidate CPU cores. Specifically, if a multi-core SoC has a homogeneous multi-core structure, that is, there are multiple cores in a SoC and all cores are of the same type (their architecture and instruction set are the same), then we consider selecting a CPU core that is in the same processor cluster as the CPU core to be migrated to obtain candidate CPU cores. If a multi-core SoC has a heterogeneous multi-core architecture, meaning that there are multiple cores in a single SoC, and all cores are not of the same type (their architectures and instruction sets are not the same), and the processor cluster corresponding to the CPU core to be migrated is overheating or overloaded, considering the increased computational demands of the process, it is advisable to select CPU cores larger than the CPU core to be migrated as candidate CPU cores. For example, migrating from a Cortex-A75 small core to a Cortex-A75 / 78 large core; considering the need for energy saving in the system, it is advisable to select CPU cores smaller than the CPU core to be migrated as candidate CPU cores. For example, migrating from a Cortex-A75 large core to a Cortex-A55 small core to save power. In summary, CPU cores located in the same processor cluster as the CPU core to be migrated are preferred as candidate CPU cores. Simply put, this means cores adjacent to the CPU core to be migrated. Selecting cores from the same processor cluster can maximize the optimal balance between performance, power consumption, and migration reliability, ensuring the practicality and effectiveness of process migration in embedded systems.
[0038] S107: Determine the target CPU core based on the real-time running status parameter value corresponding to the candidate CPU core and the preset process migration threshold.
[0039] In the embodiments of this specification, the real-time running status parameter value also includes the real-time CPU idle time; the preset process migration threshold also includes a preset CPU idle time threshold. The real-time CPU idle time is compared with the preset CPU idle time threshold, and the target CPU core is determined based on the comparison result.
[0040] In the embodiments of this specification, the real-time running status parameter value also includes the real-time CPU idle time; the preset process migration threshold also includes a preset CPU idle time threshold. The step of determining the target CPU core based on the real-time running status parameter values corresponding to the candidate CPU core and the preset process migration threshold includes: The real-time CPU idle time corresponding to the candidate CPU core is compared with the preset CPU idle time threshold to obtain the idle time comparison result; In the embodiments of this specification, the real-time running status parameter value also includes the real-time CPU idle time, that is, the CPU core has almost no tasks running during the real-time CPU idle time; the preset process migration threshold also includes the preset CPU idle time threshold, which indicates that the CPU core has sufficient resource capacity to receive new tasks. The real-time CPU idle time corresponding to the candidate CPU core is compared with the preset CPU idle time threshold to obtain the idle time comparison result, so as to determine the idle CPU core among the candidate CPU cores.
[0041] If the idle time comparison result indicates that the real-time CPU idle time corresponding to the candidate CPU core is greater than the preset CPU idle time threshold, the candidate CPU core is determined to be the target CPU core.
[0042] In the embodiments of this specification, if the idle time comparison result indicates that the real-time CPU idle time corresponding to the candidate CPU core is greater than a preset CPU idle time threshold, then the candidate CPU core is selected as the target CPU core so that the current process in the CPU core to be migrated can be migrated to the target CPU core. By filtering candidate CPU cores based on real-time CPU idle time to obtain the target CPU core, the momentary idle time caused by short-term task scheduling is effectively eliminated, ensuring that the target CPU core is in a stable and predictable idle state. At the same time, selecting an idle target CPU core helps the migrated process immediately obtain the best thermal environment and computing performance, thereby ensuring that the migration operation not only relieves the pressure on the CPU core to be migrated but also improves task execution efficiency and the overall energy efficiency ratio of the system.
[0043] S109: Obtain the current process snapshot and the target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determine the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot.
[0044] In the embodiments of this specification, on the one hand, taking centralized computing as an example, the embedded system is equipped with a dedicated service computing target incremental snapshot; specifically, after the CPU core to be migrated is selected, that is, after it is determined that the process on the CPU core to be migrated needs to be migrated, the current process on the CPU core to be migrated is frozen, and then its core running state is quickly scanned and saved to obtain the current process snapshot, thereby realizing the transformation of the dynamic running state of the current process into a static and transmittable state data packet; additionally, in order to reduce the process migration overhead, only the modified part of the process is migrated, so the target historical process snapshot corresponding to the current process in the target CPU core is obtained, which is the process snapshot saved when the current process in the target CPU core was migrated last time; Compare the current process snapshot with the target historical process snapshot, and extract the part of the current process snapshot that has changed compared to the target historical process snapshot, as the target incremental snapshot.
[0045] On the other hand, taking distributed computing as an example, the target CPU core provides a snapshot of the target's historical processes to the CPU core to be migrated, and the target incremental snapshot is calculated within the CPU core to be migrated.
[0046] This section uses centralized computing as an example for specific explanation; for distributed computing implementation methods, please refer to [link to relevant documentation]. Figure 6 The examples are illustrated below.
[0047] In this embodiment of the specification, obtaining the current process snapshot and the target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determining the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot, includes: Obtain the current process control block, current memory mapping information, current file descriptor, current peripheral status information, current process identifier, and target CPU core identifier corresponding to the current process in the CPU core to be migrated; In the embodiments of this specification, after ensuring that the process on the CPU core to be migrated needs to be migrated, the execution of the current process in the CPU core to be migrated is frozen, and then its core running state is quickly scanned and saved, including the current process control block (PCB), current memory mapping information, current file descriptor, and current peripheral status information of the current process in the CPU core to be migrated; wherein, the current process control block (PCB) is the current process's identification card, which contains the current process's ID, priority, status, register values, etc.; the current file descriptor represents the list of files, sockets, etc. currently being used by the current process and their current read / write positions, and the current file descriptor here includes the file descriptor number and the file offset. The file descriptor number is used to identify each open file, indicating which specific open file it is, and the file offset represents the current read / write position of each file, reflecting the change in the file access address; the current peripheral status information includes, for example, the context information of CAN / LIN bus communication, cached data, etc. In addition, in order to achieve incremental low-overhead migration, it is necessary to obtain the current process identifier of the current process and the target CPU core identifier corresponding to the target CPU core in order to obtain a snapshot of the target historical process.
[0048] Based on the current process control block, current memory mapping information, current file descriptor, and current peripheral status information corresponding to the CPU core to be migrated, determine the current process snapshot corresponding to the CPU core to be migrated; In the embodiments of this specification, the current process control block, current memory mapping information, current file descriptor, and current peripheral status information corresponding to the CPU core to be migrated are combined and used as a snapshot of the current process corresponding to the CPU core to be migrated.
[0049] The target CPU core snapshot relation is obtained by searching the CPU core snapshot relation library that matches the current process identifier in the preset process CPU core relation library; the preset process CPU core relation library includes the mapping relationship between preset process identifiers and preset CPU core snapshot relation libraries; the CPU core snapshot relation library includes the mapping relationship between preset CPU core identifiers and preset historical process snapshots. In the embodiments of this specification, in order to obtain a target historical process snapshot, since each process has a unique identifier in the embedded system, a preset process CPU core relationship library is set up, which includes a preset process identifier and a mapping relationship between the preset CPU core snapshot relationship library; the CPU core snapshot relationship library includes a preset CPU core identifier and a preset mapping relationship between the preset historical process snapshots; therefore, the target CPU core snapshot relationship library can be obtained by querying the preset process CPU core relationship library using the current process identifier.
[0050] Search the target CPU core snapshot database for historical process snapshots that match the target CPU core identifier to obtain the target historical process snapshot; In the embodiments of this specification, the historical process snapshot that matches the target CPU core identifier is searched in the target CPU core snapshot relation library to obtain the target historical process snapshot, that is, the historical process snapshot corresponding to the current process identifier stored in the target CPU core.
[0051] Based on the current process snapshot and the target historical process snapshot, determine the target incremental snapshot corresponding to the CPU core to be migrated.
[0052] In the embodiments of this specification, the differences between the current process snapshot and the target historical process snapshot are compared, and the portion of the current process snapshot that changes compared to the target historical process snapshot is taken as the target incremental snapshot. While obtaining the current process snapshot, the target historical process snapshot is obtained through a dual index of the current process identifier and the target CPU core identifier, and then the target incremental snapshot is calculated. This achieves precise versioned state synchronization, ensuring that incremental calculations are based on the exact base version actually possessed by the target CPU core, avoiding state inconsistencies caused by version mismatches. Furthermore, by synchronizing only the changed portions, the amount of network data transmitted is significantly reduced, significantly lowering migration latency and communication overhead in bandwidth-constrained embedded environments. Even when a process migrates back and forth between multiple CPU cores, the accuracy and reliability of state synchronization are guaranteed, enabling the embedded system to achieve efficient and reliable hot migration.
[0053] In the embodiments of this specification, the step of determining the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot is as follows: Figure 3 As shown, Figure 3This is a flowchart illustrating a method for determining a target incremental snapshot provided in an embodiment of this specification, including: S301: Obtain historical memory mapping information, historical file descriptors, and historical peripheral status information from the target historical process snapshot.
[0054] In the embodiments of this specification, the target historical process snapshot also includes historical memory mapping information, historical file descriptors, and historical peripheral status information, and these historical status data are obtained.
[0055] S302: Compare the current memory mapping information and the historical memory mapping information to obtain the memory mapping information comparison result.
[0056] In the embodiments of this specification, the current memory mapping information includes at least two memory segment identifiers and memory segment information corresponding to each of the at least two memory segment identifiers; the historical memory mapping information includes at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers; the comparison processing of the current memory mapping information and the historical memory mapping information specifically involves determining whether there is a newly added memory segment identifier and the memory segment information corresponding to that memory segment identifier in the current memory mapping information, or whether there is a memory segment identifier in the current memory mapping information in the historical memory mapping information, but the memory segment information corresponding to that memory segment identifier has changed, and these comparison results are taken as the comparison results of the memory mapping information.
[0057] In the embodiments described in this specification, the current memory mapping information includes at least two memory segment identifiers and memory segment information corresponding to each of the at least two memory segment identifiers; the historical memory mapping information includes at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers. The comparison process between the current memory mapping information and the historical memory mapping information to obtain the memory mapping information comparison result includes: Each memory segment identifier in the current memory mapping information is polled sequentially. For each polled current memory segment identifier, the existence of the current memory segment identifier is searched among the at least two historical memory segment identifiers to obtain the memory segment identifier search result. In the embodiments of this specification, the current memory mapping information includes at least two memory segments; each memory segment includes a memory segment identifier corresponding to the memory segment and memory segment information corresponding to the memory segment identifier; the historical memory mapping information includes at least two historical memory segments; each historical memory segment includes a historical memory segment identifier corresponding to the historical memory segment and historical memory segment information corresponding to the historical memory segment identifier; wherein, the memory segment identifier may include key metadata corresponding to the memory segment, such as the virtual address range / memory protection attribute / mapping type / segment flag of the memory segment; To determine incremental memory mapping information, first compare each memory segment identifier in the current memory mapping information with each historical memory segment identifier in the historical memory mapping information, and then compare the memory segment information in the current memory mapping information with the historical memory segment information in the historical memory mapping information. Therefore, each memory segment identifier in the current memory mapping information is polled in turn. For the polled current memory segment identifier, the current memory segment identifier is searched for in at least two historical memory segment identifiers. That is, it is confirmed whether the memory segment corresponding to the current memory segment identifier is a newly added memory segment, and the memory segment identifier search result is obtained. If the memory segment identifier lookup result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the memory segment identifier lookup result is used as the memory mapping information comparison result; In the embodiments of this specification, if the memory segment identifier lookup result indicates that the current memory segment identifier does not exist among at least two historical memory segment identifiers, it means that the memory segment corresponding to the current memory segment identifier is a newly added memory segment. The entire memory segment corresponding to the current memory segment identifier is directly used as the increment, and therefore the memory segment identifier lookup result is used as the memory mapping information comparison result.
[0058] If the memory segment identifier lookup result indicates that the current memory segment identifier exists among the at least two historical memory segment identifiers, the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are compared and processed to obtain the memory segment information comparison result; In the embodiments of this specification, if the memory segment identifier lookup result indicates that the current memory segment identifier exists among at least two historical memory segment identifiers, it indicates that the memory segment corresponding to the current memory segment identifier is an inherent memory segment. At this time, the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are further compared and processed to see if the current memory segment information has changed compared to the historical memory segment information, and the memory segment information comparison result is obtained.
[0059] The comparison result of the memory segment information is used as the comparison result of the memory mapping information.
[0060] In the embodiments of this specification, since incremental memory mapping information can be determined simply by comparing memory segment identifiers and memory segment information, the comparison result of memory segment information is used as the comparison result of memory mapping information. By traversing each memory segment in the current memory mapping information, the memory segment identifiers of each memory segment in the current memory mapping information and the historical memory mapping information are compared first to quickly identify newly added or deleted memory segments in the current memory mapping information, avoiding the overhead of comparing the contents of non-existent segments; for memory segment identifiers existing in the historical memory mapping information, the comparison of memory segment information is further deepened to ensure that only the memory segment information that has actually been modified is captured, filtering out unchanged data, improving the generation efficiency of incremental memory mapping information and target incremental snapshots, reducing process migration latency, and enabling the embedded system to achieve rapid hot migration.
[0061] S303: Compare the current file descriptor and the historical file descriptors to obtain the file descriptor comparison result.
[0062] In the embodiments of this specification, the current file descriptor and the historical file descriptor are compared, that is, the files opened in the current process snapshot are compared with the files opened in the target historical process snapshot, and the file pointer positions in the current process snapshot and the target historical process snapshot are compared to obtain the file descriptor comparison result.
[0063] S304: Compare the current peripheral status information and the historical peripheral status information to obtain the peripheral status information comparison result.
[0064] In the embodiments of this specification, peripheral status information may include CAN bus status (such as message queue status / filter configuration / error counter / timestamp status / working mode) / LIN bus status (such as schedule table status / frame status / slave node status / bus status) / other peripheral status (such as GPIO configuration / serial port status / timer / counter); the current peripheral status information and historical peripheral status information are compared to see if the current peripheral status information has changed compared to the historical peripheral status information, and the peripheral status information comparison result is obtained.
[0065] S305: Determine the initial incremental snapshot based on the comparison results of the memory mapping information, the file descriptor comparison results, and the peripheral status information.
[0066] In the embodiments of this specification, the changed portion of the current memory mapping information is determined based on the comparison results of the memory mapping information; the changed file offset information in the current process is determined based on the comparison results of the file descriptors; the changed portion of the current peripheral status information is determined based on the comparison results of the peripheral status information; and an initial incremental snapshot is determined based on the changed portion of the current memory mapping information, the new file in the current process, the file offset information, and the changed portion of the current peripheral status information.
[0067] In this embodiment of the specification, determining the initial incremental snapshot based on the comparison results of the memory mapping information, the file descriptor comparison results, and the peripheral status information includes: Based on the comparison results of the memory mapping information, the current memory mapping information is filtered to obtain incremental memory mapping information; In the embodiments of this specification, the current memory mapping information is filtered based on the comparison results of the memory mapping information to identify newly added memory segments and modified memory segments in the existing memory segments, and both are used as incremental memory mapping information.
[0068] In this embodiment of the specification, the step of filtering the current memory mapping information based on the comparison result of the memory mapping information to obtain incremental memory mapping information includes: If the memory mapping information comparison result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers, the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier are used as the first memory mapping information; In the embodiments of this specification, if the comparison result of memory mapping information indicates that there is no current memory segment identifier among the at least two historical memory segment identifiers, that is, the memory segment corresponding to the current memory segment identifier is a newly added memory segment, and the entire content of the memory segment is used as an increment, then the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier are used as the first memory mapping information.
[0069] If the memory mapping information comparison result indicates that the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are inconsistent, the current memory segment information shall be used as the second memory mapping information; In the embodiments of this specification, if the comparison result of memory mapping information indicates that the current memory segment information corresponding to the current memory segment identifier is inconsistent with the historical memory segment information, the part of the current memory segment information that has changed compared with the historical memory segment information shall be used as the second memory mapping information.
[0070] The incremental memory mapping information is determined based on the first memory mapping information and the second memory mapping information.
[0071] In the embodiments described in this specification, incremental memory mapping information is obtained by combining the first memory mapping information and the second memory mapping information. The incremental synchronization of memory mapping information simultaneously captures the changed data in both the newly added memory segment and the existing memory segment. This reduces the amount of memory synchronization data and ensures that the process memory allocation in the target CPU core after migration is consistent with the memory allocation in the CPU core to be migrated. This reduces migration latency and power consumption, and enables hot migration of multi-core processes in embedded systems.
[0072] If the file descriptor comparison result indicates that the current file descriptor and the historical file descriptor are inconsistent, an incremental file descriptor is determined based on the current file descriptor and the historical file descriptor; In the embodiments of this specification, if the file descriptor comparison result indicates that the current file descriptor and the historical file descriptors are inconsistent, that is, there is a newly added file descriptor number, or the file offset corresponding to the existing file descriptor number has changed, the file descriptor corresponding to the newly added file descriptor number and the file descriptor corresponding to the changed file offset are used as incremental file descriptors.
[0073] Specifically, if the current file descriptor is not included in the history file descriptors, the file corresponding to that file descriptor is determined to be a newly opened file, and the file information (file information / open mode) is recorded. If the current file descriptor is included in the history file descriptors, the file offset corresponding to that file descriptor is compared. Since file read and write operations will cause the offset to change, while file paths, permissions, and other data usually remain unchanged, only the offset information that has changed needs to be recorded. Therefore, the current file descriptor that is not included in the history file descriptors is used as the incremental file descriptor.
[0074] If the comparison result of the peripheral status information indicates that the current peripheral status information and the historical peripheral status information are inconsistent, the incremental peripheral status information is determined based on the current peripheral status information and the historical peripheral status information. In the embodiments of this specification, if the comparison result of peripheral status information indicates that the current peripheral status information and the historical peripheral status information are inconsistent, the part of the current peripheral status information that has changed compared to the historical peripheral status information is taken as the incremental peripheral status information.
[0075] The initial incremental snapshot is determined based on the incremental memory mapping information, the incremental file descriptor, and the incremental peripheral status information.
[0076] In the embodiments described in this specification, an initial incremental snapshot is obtained by combining incremental memory mapping information, incremental file descriptors, and incremental peripheral status information. Incremental synchronization is used for memory mapping information, file descriptors, and peripheral status information, transmitting only data blocks that have actually changed since the last migration. This reduces multi-core migration overhead, avoids system jitter caused by full state transmission, improves the stability of the embedded system, shortens process freeze time in the embedded environment, and ensures the service continuity of critical tasks.
[0077] S306: Determine the target incremental snapshot based on the current process control block and the initial incremental snapshot.
[0078] In the embodiments of this specification, when obtaining the process state data of the current process in the CPU core to be migrated, the current register state information of the CPU core to be migrated can also be obtained (such as the current values of all registers in the CPU core to be migrated (general purpose registers / program counter / stack pointer) / processor status word / flag register); the initial incremental snapshot, the current process control block, and the current register state information are used as the target incremental snapshot; wherein, the current process control block and the current register state information are fully synchronized; incremental synchronization is used for memory mapping information, file descriptors, and peripheral status information, which realizes accurate identification and only transmits data blocks that have been modified since the last migration, avoiding repeated transmission of unchanged content and reducing the multi-core migration overhead; since the process control block and register state information define the precise execution state of the process, any slight difference will lead to execution errors, and the data volume is small, therefore, full synchronization is used for these two, which ensures the absolute accuracy of the process control flow and maintains the complete control context, improving the reliability and efficiency of embedded system process migration, enabling the embedded system to achieve fast hot migration and meet the real-time requirements of the vehicle system.
[0079] S111: Send the target incremental snapshot to the target CPU core; so that the current process in the CPU core to be migrated is migrated to the target CPU core.
[0080] In the embodiments of this specification, in order to ensure the security performance of process migration and prevent attackers from obtaining or tampering with the target incremental snapshot through the bus, an encryption algorithm can be used to send the target incremental snapshot to the target CPU core, so that the current process in the CPU core to be migrated can be migrated to the target CPU core. After receiving the target incremental snapshot, the target CPU core decrypts it and reconstructs the process in the target CPU core according to the decrypted target incremental snapshot, so that an execution environment completely consistent with the CPU core to be migrated is created on the target CPU core, so that the current process can continue to run on the target CPU core.
[0081] In this embodiment of the specification, before sending the target incremental snapshot to the target CPU core, the method further includes: Send a memory allocation instruction to the target CPU core; so that the target CPU core allocates memory based on the memory allocation instruction to obtain the target memory space corresponding to the current process snapshot; In the embodiments of this specification, when the target incremental snapshot is generated for the CPU core to be migrated, the embedded system sends a memory allocation instruction to the target CPU core, notifying the target CPU core that a process is about to be migrated. This allows the target CPU core to allocate memory based on the memory allocation instruction. Specifically, the target CPU core checks its memory space to verify whether there is enough contiguous virtual address space, whether the required peripherals are occupied by other processes, confirm that the current security context has resource allocation permissions, and ensure that the hardware architecture and drivers corresponding to the target CPU core support the process migration requirements. After the target CPU core completes the verification, it allocates memory space (including but not limited to allocating the process control block structure, filling in process identification information, establishing the same memory mapping framework as the CPU core to be migrated, reserving peripheral register space, and establishing a file descriptor table), obtaining the target memory space corresponding to the current process snapshot. After the allocation is completed, the target CPU core can perform a self-check to ensure that the newly allocated resources do not conflict with existing resources.
[0082] In this embodiment of the specification, sending the target incremental snapshot to the target CPU core includes: Receive the memory allocation completion message sent by the target CPU core based on the memory allocation instruction.
[0083] In the embodiments of this specification, a memory allocation completion message sent by the target CPU core based on a memory allocation instruction is received, which determines that the memory allocation within the target CPU core is complete, and the target incremental snapshot can be received at any time.
[0084] Based on the memory allocation completion message, the target incremental snapshot is sent to the target memory space in the target CPU core.
[0085] In the embodiments of this specification, based on the memory allocation completion message, the target incremental snapshot is sent to the target CPU core. The target CPU core receives the target incremental snapshot and reconstructs the process in the target memory space, thereby creating an execution environment in the target CPU core that is completely consistent with the CPU core to be migrated, so that the current process in the CPU core to be migrated can continue to run normally in the target CPU core. Specifically, when sending the target incremental snapshot, in order to reduce communication overhead, the target incremental snapshot can be compressed to obtain a compressed incremental snapshot; Alternatively, to ensure data security, a lightweight symmetric encryption algorithm can be used to encrypt the compressed incremental snapshot, while attaching a hash-based message authentication code (HMAC) for verification. Specifically, AES-128 or ChaCha20 symmetric encryption algorithms can be used to encrypt the compressed incremental snapshot, resulting in an encrypted incremental snapshot. A cryptographic hash message authentication code (HMAC) is calculated for the encrypted incremental snapshot, and a unique temporary encryption key is generated for each process migration. Based on the generated temporary encryption key, the hash message authentication code, and the encrypted incremental snapshot, the encrypted migration data packet is determined. This achieves the goal of ensuring the confidentiality of the target incremental snapshot by using a symmetric encryption algorithm and ensuring the integrity of the target incremental snapshot by using a hash-based message authentication code. The encrypted migration data packet is sent to the target CPU core via the vehicle control bus (such as CAN-FD / Ethernet). After receiving the encrypted migration data packet, the target CPU core performs integrity verification and decryption processing on the encrypted migration data packet to ensure that the data to be restored is trustworthy and has not been tampered with. Specifically, it first verifies the HMAC signature to ensure that the data has not been tampered with, then uses the session key to decrypt the data, restores the compressed incremental snapshot, and immediately clears the key in memory after decryption. The target CPU core decompresses the compressed incremental snapshot to obtain the target incremental snapshot. The target CPU core writes the target incremental snapshot to the pre-allocated target memory space, establishes the same virtual memory mapping as the CPU core to be migrated, and configures read / write / execute permissions to restore the memory state, ensuring consistency with the environment of the CPU core to be migrated. Based on the file descriptor number in the incremental file descriptor, it reopens the files required by the process, locates the file position based on the file offset to restore the file state, and re-establishes the file access environment. It re-initializes the controller based on the incremental peripheral status information, restoring communication and I / O states. It loads the current values of the registers in the current process into the registers in the target CPU core, writes the current process control block to the target CPU core, and achieves final state restoration and execution preparation. During the actual process execution restoration, execution continues from the saved program counter address, the terminal is re-enabled, and the process begins to respond to events normally within the target CPU core.
[0086] After the current process is migrated from the CPU core to the target CPU core and runs normally on the target CPU core, the hook program in the embedded system will capture the process recovery event and automatically handle the remapping of network connections (such as TCP / UDP sessions) and vehicle buses (such as CAN / LIN links). For example, the embedded system will update the routing table to ensure that subsequent data packets sent to the process are directed to the target CPU core, ensuring the continuity of communication between the migrated process and the outside world, and achieving uninterrupted business. Optionally, hardware security features such as ARM TrustZone can be used before and after the process migration to measure the integrity of the code and critical data of the process on the CPU core to be migrated and the target CPU core, ensuring that it has not been damaged by malicious software and realizing the verification of a trusted execution environment. After the target CPU core confirms that the process has been successfully recovered and is running, it will send a success signal to the CPU core to be migrated. After receiving the signal, the CPU core to be migrated will destroy the migrated process, release all its memory, file descriptors and other resources, complete the process migration loop, clean up memory resources, avoid resource leaks, and reduce the load and temperature of the CPU core to be migrated. The target CPU core pre-allocates memory resources and establishes the execution environment within the target CPU core in advance, significantly reducing recovery latency. Furthermore, the target incremental snapshot transmission only synchronizes changed data, reducing network bandwidth consumption and enabling efficient migration in embedded systems. The target CPU core accurately restores the process execution context through decryption, decompression, and process reconstruction, ensuring business continuity and achieving hot migration within the embedded system. This provides high availability assurance for automotive embedded systems, while compression and encryption optimization balance performance and security requirements.
[0087] In one exemplary implementation, such as Figure 4 As shown, Figure 4 This diagram illustrates a process migration device and method for an embedded platform provided in an embodiment of this specification. Figure 4 As can be seen, the embedded platform includes a migration decision module, a process snapshot acquisition module, a state difference comparison and compression module, an encryption packaging and transmission module, a target node pre-creation resource module, a state recovery module, a connection mapping and synchronization module, a security verification module, and a module for finally releasing the source node resources. The following describes the function of each module and the process migration method of the embedded platform in the form of methods, including: S401: Migration decision module (scheduler detects trigger conditions).
[0088] In the embodiments of this specification, the migration decision is the starting point of the process migration process, ensuring that the process migration is triggered only when necessary, thus avoiding unnecessary overhead; therefore, a migration decision module is provided, which is used to detect whether there is a CPU core in the embedded system that has triggered the process migration decision condition; Specifically, an embedded system runs on the embedded platform. The migration decision module in the scheduler of the embedded system monitors the operating parameters of each CPU core in real time, including CPU utilization, CPU temperature, task priority, etc. When a specific condition is detected, such as the current core's CPU utilization exceeding 85%, temperature exceeding 80°C, or adjacent cores being idle, the migration decision module checks whether the process of the CPU core that meets the process migration conditions is in a migrateable state (such as an interrupt point or a safety checkpoint). If the process of the CPU core is in a migrateable state, the CPU core is identified as the source node, and the CPU core adjacent to the source node that has been idle for a set time threshold is identified as the target node, triggering the process migration mechanism.
[0089] S402: Process snapshot acquisition module (captures PCB, memory mapping, and other states).
[0090] In the embodiments of this specification, capturing the process state is the basis for process migration because it preserves the complete execution context of the process. Without a process snapshot, the process cannot resume running on the target CPU core. Therefore, a process snapshot acquisition module is provided. Once the existence of a source node (the CPU core to which the process needs to be migrated) is determined, the process snapshot acquisition module captures the core state data of the process running on the source node, including the process control block (PCB, such as register status and process ID), virtual memory mapping (page table information), open file descriptors (such as file handle offset), peripheral interface status (such as the current configuration of CAN and LIN buses), and register information. The snapshot data is temporarily stored in the memory of the source node to prepare for subsequent processing.
[0091] S403: State difference comparison and compression module (incremental synchronization, reducing data volume).
[0092] In the embodiments of this specification, incremental synchronization and compression can reduce communication overhead during process migration, which is especially suitable for buses with limited bandwidth in embedded environments (such as CAN-FD). This reduces migration time, saves energy, and improves the real-time performance of the embedded system. Therefore, a state difference comparison and compression module is provided. Distributed computing is used here, that is, the snapshot of the last migration in the target node is sent to the source node. The state difference comparison and compression module is used to compare the current snapshot in the source node with the snapshot of the last migration in the target node (if it is the first migration, it is compared with the initial state) to generate incremental data. This realizes synchronization of only the changed parts (such as modified pages in memory, file offset updates), and then the incremental data is compressed (using algorithms such as LZ77 or similar lightweight compression) to reduce the data volume. The incremental data acquisition process is as follows: traverse the memory mapping, open file and peripheral structure status of the current snapshot and the previous snapshot, record only the changed parts, and use full synchronization of process control block and register information, followed by compression, to ensure efficient data processing and avoid transmitting redundant information.
[0093] S404: Encrypted Packaging and Transmission Module (uses a symmetric key to encrypt and send data).
[0094] In the embodiments of this specification, in order to prevent data from being hijacked or tampered with during transmission and to ensure data transmission security, which is crucial in sensitive environments such as vehicle networks, an encryption packetization and transmission module is provided. The encryption packetization and transmission module is used to encrypt and packetize incremental data, using symmetric encryption algorithms (such as AES-CBC or ChaCha20) and HMAC for integrity verification. The encrypted data packets are sent to the target node through a control bus (such as CAN-FD or Ethernet). The transmission process may include a retransmission mechanism to ensure the reliability of data transmission.
[0095] S405: Target node pre-creates resource modules (allocates memory, initializes mapping interfaces).
[0096] In the embodiments of this specification, in order to ensure that the target node has a sufficient execution environment, avoid the dynamic allocation overhead during process recovery, improve migration speed, and ensure that the process can be seamlessly taken over, a target node pre-creation resource module is set up. The target node pre-creation resource module is used to pre-allocate resources on the target node, including memory space (for loading process state), I / O mapping area (such as peripheral registers), and initialization of necessary kernel interfaces. Moreover, the memory resource allocation process can be performed at the same time as data transmission or immediately afterward to minimize latency.
[0097] S406: State recovery module (load snapshot, rebuild process context).
[0098] In the embodiments described in this specification, a state recovery module is provided to ensure that the process continues to run on the target node and maintains business continuity. This module decrypts and verifies the integrity of the encrypted data received on the target node. Then, it reconstructs the process based on the snapshot data. Specifically, it allocates memory and loads the decompressed memory mapping, restores the register state, reopens the file and locates the correct offset, and sets the PCB. Finally, the process resumes execution from the checkpoint, ensuring the accurate reconstruction of the process context.
[0099] S407: Connection Mapping and Synchronization Module (Network / CAN / LIN Interface Keep Session Recovered).
[0100] In the embodiments of this specification, in order to prevent network or bus interruption caused by migration and ensure uninterrupted service, and to avoid communication timeouts or errors for real-time systems such as vehicle controllers, a connection mapping and synchronization module is provided. The connection mapping and synchronization module is used to automatically map the network connection (such as TCP / UDP session) or vehicle bus connection (such as CAN link) of the process using Hook (such as network stack or bus driver), ensuring that the IP address, port or bus identifier remains unchanged on the target node.
[0101] S408: Security verification module (TrustZone integrity verification).
[0102] In the embodiments of this specification, in order to prevent migration failure caused by malicious attacks or hardware failures and to enhance the reliability of process migration in the embedded system, a security verification module may be optionally provided. The security verification module is used to verify the integrity of the migration process using a trusted execution environment (TEE) such as ARM TrustZone, for example, checking whether the snapshot data has been tampered with or whether the process code is complete. After the verification is passed, the process is marked as a runnable process.
[0103] S409: Release source node resources.
[0104] In the embodiments of this specification, in order to avoid resource leakage and improve the resource utilization of the embedded system, after confirming that the target node process has been successfully restored, the source node releases the resources of the migrated process, including memory, file descriptors and peripheral device usage; at the same time, it notifies the scheduling system that the migration is complete and the source node can receive new tasks.
[0105] In this embodiment, the migration decision module within the embedded system uses a scheduler to monitor parameters such as CPU load temperature and idle time in real time to obtain the source node and target node, automatically triggering the migration. A process snapshot acquisition module captures core states of the process in the source node, including process control blocks, memory mappings, file descriptors, peripheral interface states, and register information. A state difference comparison and compression module compares the current process snapshot with the previous snapshot in the target node, synchronizing only the changed parts of memory mappings, file descriptors, and peripheral interface states (incremental synchronization), while performing full synchronization of process control blocks and register information, significantly reducing data volume, bandwidth requirements, and migration time. An encryption, packaging, and transmission module encrypts data using a symmetric key before sending it to the target node via the bus, effectively resisting theft and tampering, and improving the robustness and resource utilization of the embedded system (such as an vehicle controller). The target node sequentially executes a pre-creation resource module to allocate memory, a state recovery module to rebuild the process context, and a connection mapping and synchronization module to restore network and bus sessions, ensuring process continuity and uninterrupted external sessions. Optionally, a security verification module uses TrustZone for integrity verification, ultimately releasing the source node resources.
[0106] This manual also provides process migration devices for embedded systems, such as... Figure 5 As shown, the embedded system includes at least two CPU cores, and the device includes: The first acquisition module 501 is used to acquire the real-time running status parameter values corresponding to each of the at least two CPU cores and the preset process migration threshold; the preset process migration threshold is the upper limit of the running status parameters that the process within the CPU core needs to migrate. The CPU core to be migrated determination module 502 is used to filter the at least two CPU cores according to the real-time running status parameter value and the preset process migration threshold to obtain the CPU cores to be migrated. The candidate CPU core determination module 503 is used to filter CPU cores that are in the same processor cluster as the CPU core to be migrated from the at least two CPU cores to obtain candidate CPU cores; The target CPU core determination module 504 is used to determine the target CPU core based on the real-time running status parameter value corresponding to the candidate CPU core and the preset process migration threshold. The target incremental snapshot determination module 505 is used to obtain the current process snapshot and the target historical process snapshot corresponding to the current process in the CPU core to be migrated, and determine the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot. Migration module 506 is used to send the target incremental snapshot to the target CPU core so that the current process in the CPU core to be migrated can be migrated to the target CPU core.
[0107] In some embodiments, the real-time running status parameter values include real-time CPU utilization and real-time CPU temperature values; the preset process migration threshold includes a preset CPU utilization threshold and a preset CPU temperature threshold; the CPU core to be migrated determination module further includes: The CPU utilization comparison result determination submodule is used to compare the real-time CPU utilization corresponding to each of the at least two CPU cores with the preset CPU utilization threshold to obtain the CPU utilization comparison result corresponding to each of the at least two CPU cores. The temperature comparison result determination submodule is used to compare the real-time CPU temperature value corresponding to each of the at least two CPU cores with the preset CPU temperature threshold to obtain the temperature comparison result corresponding to each of the at least two CPU cores. The CPU core to be migrated submodule is used to select CPU cores from the at least two CPU cores whose real-time CPU utilization is greater than the preset CPU utilization threshold and whose real-time CPU temperature is greater than the preset CPU temperature threshold, based on the CPU utilization comparison results and temperature comparison results corresponding to the at least two CPU cores respectively, so as to obtain the CPU cores to be migrated.
[0108] In some embodiments, the real-time running status parameter value further includes real-time CPU idle time; the preset process migration threshold further includes a preset CPU idle time threshold; the target CPU core determination module further includes: The idle time comparison result determination submodule is used to compare the real-time CPU idle time corresponding to the candidate CPU core with the preset CPU idle time threshold to obtain the idle time comparison result; The target CPU core determination submodule is used to determine the candidate CPU core as the target CPU core if the idle time comparison result indicates that the real-time CPU idle time corresponding to the candidate CPU core is greater than the preset CPU idle time threshold.
[0109] In some embodiments, the target incremental snapshot determination module further includes: The acquisition submodule is used to acquire the current process control block, current memory mapping information, current file descriptor, current peripheral status information, current process identifier, and target CPU core identifier corresponding to the current process in the CPU core to be migrated; The current process snapshot determination submodule is used to determine the current process snapshot corresponding to the CPU core to be migrated based on the current process control block, current memory mapping information, current file descriptor, and current peripheral status information corresponding to the CPU core to be migrated. The target CPU core snapshot relationship library determination submodule is used to search for the CPU core snapshot relationship library that matches the current process identifier in the preset process CPU core relationship library to obtain the target CPU core snapshot relationship library; the preset process CPU core relationship library includes preset process identifiers and the mapping relationship between preset CPU core snapshot relationship libraries; the CPU core snapshot relationship library includes preset CPU core identifiers and the mapping relationship between preset historical process snapshots; The target historical process snapshot determination submodule is used to search for a historical process snapshot that matches the target CPU core identifier in the target CPU core snapshot relationship library, and obtain the target historical process snapshot. The target incremental snapshot determination submodule is used to determine the target incremental snapshot corresponding to the CPU core to be migrated based on the current process snapshot and the target historical process snapshot.
[0110] In some embodiments, the target incremental snapshot determination submodule further includes: The acquisition unit is used to acquire historical memory mapping information, historical file descriptors, and historical peripheral status information from the target historical process snapshot; The memory mapping information comparison result determination unit is used to compare the current memory mapping information and the historical memory mapping information to obtain the memory mapping information comparison result. The file descriptor comparison result determination unit is used to compare the current file descriptor and the historical file descriptors to obtain the file descriptor comparison result; The peripheral status information comparison result determination unit is used to compare the current peripheral status information and the historical peripheral status information to obtain the peripheral status information comparison result. An initial incremental snapshot determination unit is used to determine an initial incremental snapshot based on the comparison results of the memory mapping information, the comparison results of the file descriptors, and the comparison results of the peripheral status information. The target incremental snapshot determination unit is used to determine the target incremental snapshot based on the current process control block and the initial incremental snapshot.
[0111] In some embodiments, the current memory mapping information includes at least two memory segment identifiers and memory segment information corresponding to each of the at least two memory segment identifiers; the historical memory mapping information includes at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers; the memory mapping information comparison result determination unit further includes: The memory segment identifier lookup result determination subunit is used to sequentially poll each memory segment identifier in the current memory mapping information, and for the polled current memory segment identifier, to search whether the current memory segment identifier exists in at least two historical memory segment identifiers, so as to obtain the memory segment identifier lookup result; The first memory mapping information comparison result determination subunit is used to take the memory segment identifier search result as the memory mapping information comparison result if the memory segment identifier search result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers. The memory segment information comparison result determination subunit is used to compare the current memory segment information corresponding to the current memory segment information and the historical memory segment information if the memory segment identifier lookup result indicates that the current memory segment identifier exists among the at least two historical memory segment identifiers, and to obtain the memory segment information comparison result. The second memory mapping information comparison result determination subunit is used to take the memory segment information comparison result as the memory mapping information comparison result.
[0112] In some embodiments, the initial incremental snapshot determination unit further includes: The incremental memory mapping information determination subunit is used to filter the current memory mapping information based on the memory mapping information comparison result to obtain incremental memory mapping information; An incremental file descriptor determination subunit is used to determine an incremental file descriptor based on the current file descriptor and the historical file descriptor if the file descriptor comparison result indicates that the current file descriptor and the historical file descriptor are inconsistent. An incremental peripheral status information determination subunit is used to determine incremental peripheral status information based on the current peripheral status information and the historical peripheral status information if the peripheral status information comparison result indicates that the current peripheral status information and the historical peripheral status information are inconsistent. The initial incremental snapshot determination subunit is used to determine the initial incremental snapshot based on the incremental memory mapping information, the incremental file descriptor, and the incremental peripheral status information.
[0113] In some embodiments, the incremental memory mapping information determination subunit further includes: The first memory mapping information determination component is used to determine the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier as the first memory mapping information if the memory mapping information comparison result indicates that the current memory segment identifier does not exist among the at least two historical memory segment identifiers. The second memory mapping information determination component is used to determine the current memory segment information as the second memory mapping information if the memory mapping information comparison result indicates that the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are inconsistent. An incremental memory mapping information determination component is used to determine the incremental memory mapping information based on the first memory mapping information and the second memory mapping information.
[0114] In some embodiments, the apparatus further includes: A memory allocation module is used to send a memory allocation instruction to the target CPU core, so that the target CPU core can allocate memory based on the memory allocation instruction to obtain the target memory space corresponding to the current process snapshot. In some embodiments, the migration module further includes: The receiving submodule is used to receive the memory allocation completion message sent by the target CPU core based on the memory allocation instruction; The migration submodule is used to send the target incremental snapshot to the target memory space in the target CPU core based on the memory allocation completion message.
[0115] The apparatus and method embodiments described herein are based on the same inventive concept.
[0116] This specification provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program, which is loaded and executed by the processor to implement the process migration method of the embedded system provided in the above method embodiments.
[0117] Embodiments of this application also provide a computer storage medium, which can be disposed in a terminal to store at least one instruction or at least one program related to implementing a process migration method of an embedded system in the method embodiments. The at least one instruction or at least one program is loaded and executed by the processor to implement the process migration method of the embedded system provided in the above method embodiments.
[0118] Embodiments of this application also provide a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the process migration method for the embedded system provided in the above-described method embodiments.
[0119] The memory described in the embodiments of this specification can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for the functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0120] The process migration method for embedded systems provided in this specification can be executed on mobile terminals, computer terminals, servers, or similar computing devices. Taking running on a server as an example... Figure 6 This is a hardware structure block diagram of a server for an embedded system process migration method provided in the embodiments of this specification. (Example:) Figure 6As shown, the server 600 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 610 (CPUs 610 may include, but are not limited to, microprocessors (MCUs) or programmable logic devices (FPGAs), a memory 630 for storing data, and one or more storage media 620 (e.g., one or more mass storage devices) for storing application programs 623 or data 622. The memory 630 and storage media 620 may be temporary or persistent storage. The program stored in the storage media 620 may include one or more modules, each module may include a series of instruction operations on the server. Furthermore, the CPU 610 may be configured to communicate with the storage media 620 and execute the series of instruction operations stored in the storage media 620 on the server 600. Server 600 may also include one or more power supplies 660, one or more wired or wireless network interfaces 650, one or more input / output interfaces 640, and / or one or more operating systems 621, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0121] The input / output interface 640 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of server 600. In one example, input / output interface 640 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, input / output interface 640 may be a radio frequency (RF) module used for wireless communication with the Internet.
[0122] Those skilled in the art will understand that Figure 6 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, server 600 may also include... Figure 6 The more or fewer components shown, or having the same Figure 6 The different configurations shown.
[0123] As can be seen from the embodiments of the embedded system process migration method and apparatus provided in this application, this application obtains the real-time running status parameter values corresponding to each of the at least two CPU cores and a preset process migration threshold; the preset process migration threshold is the upper limit of the running status parameters required for the migration of processes within a CPU core; based on the real-time running status parameter values and the preset process migration threshold, the at least two CPU cores are screened to obtain CPU cores to be migrated; among the at least two CPU cores, CPU cores located in the same processor cluster as the CPU core to be migrated are screened to obtain candidate CPU cores; based on the real-time running status parameter values corresponding to the candidate CPU cores and the preset process migration threshold, a target CPU core is determined; a current process snapshot and a target historical process snapshot corresponding to the current process in the CPU core to be migrated are obtained, and based on the current process snapshot and the target historical process snapshot, a target incremental snapshot corresponding to the CPU core to be migrated is determined; the target incremental snapshot is sent to the target CPU core; so that the current process in the CPU core to be migrated is migrated to the target CPU core. This system monitors the real-time CPU utilization and temperature of at least two CPU cores in an embedded system. Combined with a preset process migration threshold, it filters out CPU cores to be migrated when real-time running status parameters exceed this threshold, precisely locating the CPU core to be migrated. It then selects candidate CPU cores located within the same processor cluster as the CPU core to be migrated, and determines the target CPU core based on the real-time CPU idle time of these candidate CPU cores, improving the reliability of process migration. Finally, it determines the target incremental snapshot based on the current process snapshot and the target's historical process snapshot, employing incremental synchronization for memory mapping information, file descriptors, and peripheral status information. This achieves accurate identification and transmission of only data blocks modified since the last migration, making the migration process lightweight and reducing the burden on multi-core embedded systems. The process migration overhead of the embedded system is minimized, making the process migration process imperceptible to upper-layer applications and ensuring driving safety. Full synchronization is used for process control blocks and register state information, ensuring both the absolute accuracy of process control flow and maintaining a complete control context. This improves the reliability and efficiency of embedded system process migration, enabling rapid hot migration and meeting the real-time requirements of automotive systems. The execution environment is pre-established within the target CPU core, significantly reducing recovery latency. The target CPU core accurately restores the process execution context through decryption, decompression, and process reconstruction, ensuring business continuity. This achieves hot migration within the embedded system while ensuring the safety of embedded system process migration, providing high availability assurance for automotive embedded systems and enabling rapid hot migration in the event of a main control failure.
[0124] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments of this specification have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0125] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0126] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer storage medium, such as a read-only memory, a disk, or an optical disk.
[0127] The above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A process migration method of an embedded system, characterized by, The embedded system comprises at least two CPU cores, and the method comprises the following steps: obtaining real-time running state parameter values corresponding to the at least two CPU cores respectively and a preset process migration threshold value; the preset process migration threshold value is an upper limit value of a running state parameter required to be migrated by a process in a CPU core; performing screening processing on the at least two CPU cores according to the real-time running state parameter values and the preset process migration threshold value to obtain a to-be-migrated CPU core; screening, from the at least two CPU cores, a CPU core that is in the same processor cluster as the to-be-migrated CPU core to obtain a candidate CPU core; determining a target CPU core according to real-time running state parameter values corresponding to the candidate CPU core and the preset process migration threshold value; obtaining a current process snapshot corresponding to a current process in the to-be-migrated CPU core and a target historical process snapshot, and determining a target incremental snapshot corresponding to the to-be-migrated CPU core according to the current process snapshot and the target historical process snapshot; sending the target incremental snapshot to the target CPU core, so that the current process in the to-be-migrated CPU core is migrated to the target CPU core.
2. The method of claim 1, wherein, The real-time running state parameter values comprise real-time CPU utilization and real-time CPU temperature values; The preset process migration threshold value comprises a preset CPU utilization threshold value and a preset CPU temperature threshold value; The screening processing on the at least two CPU cores according to the real-time running state parameter values and the preset process migration threshold value to obtain the to-be-migrated CPU core comprises the following steps: comparing real-time CPU utilization corresponding to the at least two CPU cores respectively with the preset CPU utilization threshold value to obtain CPU utilization comparison results corresponding to the at least two CPU cores respectively; comparing real-time CPU temperature values corresponding to the at least two CPU cores respectively with the preset CPU temperature threshold value to obtain temperature comparison results corresponding to the at least two CPU cores respectively; screening, from the at least two CPU cores, a CPU core whose real-time CPU utilization is greater than the preset CPU utilization threshold value and whose real-time CPU temperature value is greater than the preset CPU temperature threshold value according to the CPU utilization comparison results and the temperature comparison results corresponding to the at least two CPU cores respectively to obtain the to-be-migrated CPU core.
3. The method of claim 2, wherein, The real-time running state parameter values further comprise real-time CPU idle time lengths; and the preset process migration threshold value further comprises a preset CPU idle time length threshold value; The determination of the target CPU core according to the real-time running state parameter values corresponding to the candidate CPU core and the preset process migration threshold value comprises the following steps: comparing real-time CPU idle time lengths corresponding to the candidate CPU core with the preset CPU idle time length threshold value to obtain an idle time length comparison result; if the idle time length comparison result indicates that the real-time CPU idle time length corresponding to the candidate CPU core is greater than the preset CPU idle time length threshold value, the candidate CPU core is determined as the target CPU core.
4. The method of claim 3, wherein, The obtaining of the current process snapshot corresponding to a current process in the to-be-migrated CPU core and the target historical process snapshot, and the determination of the target incremental snapshot corresponding to the to-be-migrated CPU core according to the current process snapshot and the target historical process snapshot, comprises: obtaining a current process control block, current memory mapping information, current file descriptors, current peripheral state information, a current process identifier corresponding to a current process in the to-be-migrated CPU core, and a target CPU core identifier corresponding to the target CPU core; determining the current process snapshot corresponding to the to-be-migrated CPU core according to the current process control block, the current memory mapping information, the current file descriptors, and the current peripheral state information of the to-be-migrated CPU core; finding a CPU core snapshot relationship library matched with the current process identifier in a preset process CPU core relationship library to obtain a target CPU core snapshot relationship library; the preset process CPU core relationship library comprises a preset mapping relationship between a preset process identifier and a preset CPU core snapshot relationship library; the CPU core snapshot relationship library comprises a preset mapping relationship between a preset CPU core identifier and a preset historical process snapshot; finding a historical process snapshot matched with the target CPU core identifier in the target CPU core snapshot relationship library to obtain the target historical process snapshot; determining the target incremental snapshot corresponding to the to-be-migrated CPU core according to the current process snapshot and the target historical process snapshot.
5. The method of claim 4, wherein, The determination of the target incremental snapshot corresponding to the to-be-migrated CPU core according to the current process snapshot and the target historical process snapshot comprises: obtaining historical memory mapping information, historical file descriptors, and historical peripheral state information in the target historical process snapshot; comparing the current memory mapping information and the historical memory mapping information to obtain a memory mapping information comparison result; comparing the current file descriptors and the historical file descriptors to obtain a file descriptor comparison result; comparing the current peripheral state information and the historical peripheral state information to obtain a peripheral state information comparison result; determining an initial incremental snapshot according to the memory mapping information comparison result, the file descriptor comparison result, and the peripheral state information comparison result; determining the target incremental snapshot according to the current process control block and the initial incremental snapshot.
6. The method of claim 5, wherein, The current memory mapping information comprises at least two memory segment identifiers and memory segment information corresponding to each of the at least two memory segment identifiers; the historical memory mapping information comprises at least two historical memory segment identifiers and historical memory segment information corresponding to each of the at least two historical memory segment identifiers; The comparison of the current memory mapping information and the historical memory mapping information to obtain a memory mapping information comparison result comprises: sequentially polling each memory segment identifier in the current memory mapping information, and finding whether the current memory segment identifier exists in the at least two historical memory segment identifiers for the polled current memory segment identifier to obtain a memory segment identifier finding result; If the memory segment identifier lookup result represents that the current memory segment identifier does not exist in the at least two historical memory segment identifiers, the memory segment identifier lookup result is taken as the memory mapping information comparison result; If the memory segment identifier lookup result represents that the current memory segment identifier exists in the at least two historical memory segment identifiers, the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are compared to obtain a memory segment information comparison result; The memory segment information comparison result is taken as the memory mapping information comparison result.
7. The method of claim 6, wherein, The determining of the initial incremental snapshot according to the memory mapping information comparison result, the file descriptor comparison result and the peripheral state information comparison result comprises: The current memory mapping information is filtered according to the memory mapping information comparison result to obtain incremental memory mapping information; If the file descriptor comparison result represents that the current file descriptor and the historical file descriptor are inconsistent, the incremental file descriptor is determined according to the current file descriptor and the historical file descriptor; If the peripheral state information comparison result represents that the current peripheral state information and the historical peripheral state information are inconsistent, the incremental peripheral state information is determined according to the current peripheral state information and the historical peripheral state information; The initial incremental snapshot is determined according to the incremental memory mapping information, the incremental file descriptor and the incremental peripheral state information.
8. The method of claim 7, wherein, The filtering of the current memory mapping information according to the memory mapping information comparison result to obtain incremental memory mapping information comprises: If the memory mapping information comparison result represents that the current memory segment identifier does not exist in the at least two historical memory segment identifiers, the current memory segment identifier and the current memory segment information corresponding to the current memory segment identifier are taken as first memory mapping information; If the memory mapping information comparison result represents that the current memory segment information corresponding to the current memory segment identifier and the historical memory segment information are inconsistent, the current memory segment information is taken as second memory mapping information; The incremental memory mapping information is determined according to the first memory mapping information and the second memory mapping information.
9. The method of claim 1, wherein, Before the sending of the target incremental snapshot to the target CPU core, the method further comprises: sending a memory allocation instruction to the target CPU core, so that the target CPU core performs allocation processing on the memory of the target CPU core based on the memory allocation instruction to obtain a target memory space corresponding to the current process snapshot; The sending of the target incremental snapshot to the target CPU core comprises: receiving a memory allocation completion message sent by the target CPU core based on the memory allocation instruction; sending the target incremental snapshot to the target memory space in the target CPU core based on the memory allocation completion message.
10. An apparatus for process migration of an embedded system, characterized in that, The embedded system comprises at least two CPU cores, and the device comprises: The first obtaining module is configured to obtain real-time running state parameter values corresponding to the at least two CPU cores respectively and a preset process migration threshold value; the preset process migration threshold value is an upper limit value of a running state parameter required to be migrated by a process in a CPU core; The to-be-migrated CPU core determining module is configured to perform screening processing on the at least two CPU cores according to the real-time running state parameter values and the preset process migration threshold value, and obtain a to-be-migrated CPU core; The candidate CPU core determining module is configured to screen, from the at least two CPU cores, a CPU core that is in a same processor cluster as the to-be-migrated CPU core, and obtain a candidate CPU core; The target CPU core determining module is configured to determine a target CPU core according to real-time running state parameter values corresponding to the candidate CPU core and the preset process migration threshold value; The target incremental snapshot determining module is configured to obtain a current process snapshot corresponding to a current process in the to-be-migrated CPU core and a target historical process snapshot, and determine a target incremental snapshot corresponding to the to-be-migrated CPU core according to the current process snapshot and the target historical process snapshot; The migration module is configured to send the target incremental snapshot to the target CPU core, so that the current process in the to-be-migrated CPU core is migrated to the target CPU core.
