Process recovery method, product, equipment and storage medium
By adding magic numbers to the process control block during kernel switching to quickly identify and retain key memory data, the problem of time spent reading disk memory data during kernel switching is solved, and the effect of rapid process recovery and shortening business interruption time is achieved.
Patent Information
- Application Number
- CN202510237669.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-02-28
AI Technical Summary
During kernel switching, it takes a long time to read memory data from disk and put it back into memory, resulting in extended business interruption time.
By adding magic numbers to the corresponding process control blocks of the target software, we quickly identify and retain key memory data, and directly restore process in system memory to reduce dependence on disk.
Reduces the time-consuming process recovery, improves recovery efficiency, shortens business interruption time, and reduces the impact of kernel switching on the business.
Smart Images

Figure CN120029827A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a process recovery method, product, device and storage medium. Background Art
[0002] In the development process of large-scale software, vulnerabilities are inevitable. As the core of the operating system, the kernel (such as the Linux kernel) may cause system crashes, data leaks, and even remote control if its vulnerabilities are maliciously exploited. Kernel upgrades can fix these known vulnerabilities and reduce the risk of being attacked. Regular kernel updates can introduce new security features and defense mechanisms, improve the system's defense capabilities against new attacks, and improve the security and stability of the business.
[0003] However, as the core of the operating system, switching the kernel requires restarting the system, completely shutting down the current kernel, and booting the system from the new kernel to complete the kernel switch. For example, the current Linux operating system usually updates the kernel through the Kexec tool (a system call tool) or restarting, and saves and restores the process data by restarting the software or using the CRIU (Checkpoint / Restore In Userspace, a tool that provides checkpoint / recovery functions for Linux) tool to achieve kernel upgrade and restore process. However, the above kernel update method requires the restart system call to complete the shutdown of the old kernel and the startup of the new kernel; and in actual use, the memory of the key process is usually large. The method of reading the memory data and writing it to the disk, and then reading the saved memory data from the disk and putting it back to the memory will be very time-consuming, resulting in a longer business interruption. In addition, during the restart of the operating system, the software running on the system will be terminated, and the system will be unavailable for a short time, thus affecting the ongoing business operations. Summary of the invention
[0004] The present application provides a process recovery method, product, device and storage medium to at least solve the time-consuming problem of reading memory data in a disk and putting it back into memory during process recovery in the related art.
[0005] The present application provides a process recovery method, including:
[0006] When a kernel switching task needs to be executed, the process control block containing the preset magic number in the current system memory is detected;
[0007] Run the target process corresponding to the target software that needs to perform kernel switching, and collect context information during the running of the target process to obtain process context information;
[0008] Loading a new kernel into a preset memory space, and restarting the operating system from the new kernel in the preset memory space;
[0009] When a new kernel is detected to be started, the process control block is identified based on the preset magic number in the target memory address, and the data in the process control block and the process context information are retained in the system memory;
[0010] When it is detected that the operating system is started, the process context information and the data in the process control block are read to create a new process in the system memory, and the target process is restored in the new process based on the process context information and the data in the process control block.
[0011] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned process recovery methods when executing the computer program.
[0012] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned process recovery methods are implemented.
[0013] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned process recovery methods when executed by a processor.
[0014] Through the present application, since a magic number is added to the process control block corresponding to the target software in advance, the process control block corresponding to the target software can be quickly identified based on the magic number when the process is recovered; and, when the present application detects that a new kernel is started, the process control block is identified based on the magic number in the target memory address, and the data in the process control block and the process context information during the operation of the target process are retained in the system memory, so that the target process can be directly restored according to the information recorded in the system memory (including the data in the process control block corresponding to the target process and the process context information). Compared with the process recovery method of saving process recovery data in the disk and reading process recovery data from the disk, by adding a magic number in the process control block and identifying and retaining key memory data for process data recovery after the new kernel is started, the data recovery process from the disk to the memory can be reduced, and the time consumption of process recovery can be reduced, thereby improving the efficiency of process recovery and reducing the impact on business operations. Therefore, the time-consuming problem of reading memory data from the disk and putting it back into the memory during process recovery can be solved, achieving the technical effect of greatly improving the process recovery speed, shortening the business interruption time, and reducing the impact of kernel switching on the business. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 A process recovery method flow chart provided in an embodiment of the present application;
[0017] Figure 2 A schematic diagram of system memory before process recovery provided in an embodiment of the present application;
[0018] Figure 3 A schematic diagram of system memory after a process is restored provided in an embodiment of the present application;
[0019] Figure 4 A flowchart of a specific process recovery method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0022] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0023] The present application embodiment discloses a process recovery method, see Figure 1 As shown, the method includes:
[0024] Step S11: When a kernel switching task needs to be executed, a process control block containing a preset magic number in the current system memory is detected.
[0025] In this embodiment, when the operating system (such as the Linux kernel) needs to execute a kernel switching task (such as kernel upgrade / downgrade), the memory usage of the process that needs to be quickly restored after the kernel switch is first detected. Specifically, the distribution of key memory data flags (i.e., preset magic numbers) in the system memory is detected, thereby obtaining a process control block (PCB, process ctrl block) containing the preset magic number.
[0026] Among them, the process control block is a data structure used by the operating system to manage the process. It contains all important information related to the process. The saved information may include: 1. Process status information, which is used to indicate the current status of the process (such as ready, running, waiting, etc.); 2. Program counter information, which is used to point to the address of the next instruction to be executed; 3. Register information, including general registers, stack pointers, etc., which records the status of the process at runtime; 4. Memory management information, such as page tables or segment tables, which records the memory address information used by the process; 5. Scheduling information, such as priority, scheduling queue pointer, etc., which is used for process scheduling; 6. I / O (Input / Output) status information, which records the I / O devices and related information used by the process.
[0027] It should be pointed out that before the process is restored, the application needs to prepare the corresponding system environment to implement the process recovery process. Specifically, before detecting the process control block containing the preset magic number in the current system memory, it also includes: configuring the system startup boot parameter; the system startup boot parameter includes the first boot parameter, the second boot parameter and the third boot parameter; wherein the first boot parameter is used to specify the target memory address to save the critical memory data flag, the second boot parameter is used to indicate whether to choose to retain the critical memory data, and the third boot parameter is used to specify the preset magic number as the critical memory data flag; when the operating system is detected to be started, the preset magic number is added to the target memory address located in the system memory; during the operation of the operating system, it is determined whether the target software needs to resume operation after the kernel switch; if the target software needs to resume operation after the kernel switch, the preset system tool is called to start the target process corresponding to the target software, and the preset magic number located in the target memory address is added to the process control block of the target process. In this embodiment, three system startup boot parameters are pre-configured, namely the first boot parameter (boot parameter 1), the second boot parameter (boot parameter 2) and the third boot parameter (boot parameter 3); wherein the first boot parameter (boot parameter 1) is used to specify a target memory address to save the critical memory data flag, the second boot parameter (boot parameter 2) is used to indicate whether to choose to retain the critical memory data, and the third boot parameter (boot parameter 3) is used to specify a preset magic number as the critical memory data flag. Among them, the preset magic number refers to the numerical constant of the critical memory data flag; the critical memory data refers to all the memory data required to restore a target process. Then, when it is detected that the operating system is started, the preset magic number is added to the target memory address located in the system memory, and during the operation of the operating system, it is determined whether the target software that needs to perform kernel switching needs to resume operation after the kernel switch. If it needs to resume operation after the kernel switch, the preset system tool is called to start the target process corresponding to the target software, and the preset magic number (i.e., the critical memory data flag) located in the target memory address is added to the process control block of the target process, see. Figure 2 As shown, a magic number is set in the system memory, and the magic number is added to the process control block of the target process. By adding the magic number, the relevant process control blocks of the target process can be quickly and accurately identified, thereby facilitating the search and recovery of the process control blocks in the subsequent process recovery process, thereby improving the efficiency of process recovery.
[0028] In a specific embodiment, adding a preset magic number to a target memory address in the system memory may specifically include: generating a random number through a true random function, and adding the generated random number as the preset magic number to the target memory address in the system memory. In this embodiment, a random number may be first generated through a true random function, and then the random number may be added as the preset magic number to the target memory address in the system memory. Generating the magic number by using a true random function to generate a random number may avoid data collision.
[0029] In another specific embodiment, the preset magic number can also be specified through a command line parameter. In addition, after the operating system is started, a / proc / magicnum interface can be provided to view the specific value of the preset magic number. Among them, / proc is a virtual file system that provides an interface through which kernel and process information can be accessed, providing a view of kernel data for user space programs, so that users can obtain system status and process information by reading files.
[0030] Specifically, adding a preset magic number located at the target memory address in the process control block of the target process may include: adding the preset magic number located at the target memory address in the process control block of the target process and the process control block of the child process generated by the target process. In this embodiment, if the target process has been started, the system tool can be used to add a key memory data flag (i.e., the preset magic number) to the process control block of the current target process, and at the same time, the same key memory data flag (i.e., the preset magic number) will also be set in the process control block of the child process generated by the target process.
[0031] Step S12: running the target process corresponding to the target software that needs to perform kernel switching, and collecting context information during the running of the target process to obtain process context information.
[0032] In this embodiment, after detecting the process control block containing the preset magic number in the current system memory, further, the target process corresponding to the target software that needs to perform kernel switching is run, and the context information of the target process during operation is collected to obtain process context information. The process context information includes but is not limited to file description information ( / proc / pid / fd / and / proc / pid / fdinfo / ), register status information, inter-process communication parameter information, memory table ( / proc / pid / maps / and / proc / pid / map_files / ), process environment ( / proc / pid / environ and / proc / pid / cmdline) information, process tree information, etc.
[0033] Specifically, running the target process corresponding to the target software that needs to perform kernel switching, and collecting context information during the running of the target process to obtain the process context information may include: dynamically injecting the target process corresponding to the target software that needs to perform kernel switching through a system call mechanism, and running the target process; collecting context information during the running of the target process from a preset virtual file system to obtain the process context information. For example, dynamically injecting the target process corresponding to the target software that needs to perform kernel switching through a ptrace (a Linux system call) mechanism and running the target process, and then collecting all context information of the target process from the / proc file system (a virtual file system in Linux).
[0034] Furthermore, after collecting the context information of the target process during its operation and obtaining the process context information, it may also include: saving the process context information and the data in the process control block to the disk in the form of an image file; the process context information includes the memory table and the process tree information; and recording the address and length of the key memory area occupied by the target process on the disk. In this embodiment, after collecting all the data related to the target process (including the process context information and the data in the process control block), it is saved to the disk in the form of an image file, and the address and length of the key memory area occupied by the target process are recorded on the disk. It is understandable that if the target process has a large memory usage, it will be very time-consuming to save the memory data to the disk in the form of an image file. At this time, you can choose to give up saving the memory image data and only keep the memory table in the context information.
[0035] Step S13: Load the new kernel into the preset memory space, and restart the operating system from the new kernel in the preset memory space.
[0036] In this embodiment, after collecting the context information of the target process during operation, the kernel switch can be performed through the Kexec tool. Specifically, the new kernel can be first loaded into the preset memory space in the system memory, and then the operating system can be restarted from the loaded new kernel through the system restart call. Compared with directly restarting the system to switch the kernel, the hardware boot process and the kernel loading time during booting can be reduced.
[0037] Step S14: When it is detected that a new kernel is started, a process control block is identified based on a preset magic number in the target memory address, and data in the process control block and process context information are retained in the system memory.
[0038] In this embodiment, when a new kernel startup is detected, the corresponding process control block can be identified based on the preset magic number stored in the target memory address, and then the data and process context information in the identified process control block are retained in the system memory.
[0039] Specifically, when a new kernel is detected to be started, the process control block is identified based on the preset magic number in the target memory address, which may include: when a new kernel is detected to be started, the second boot parameter in the system boot parameter is detected, if the second boot parameter indicates that the key memory data is selected to be retained, the target memory address for storing the key memory data flag is detected, and the preset magic number is read from the target memory address; when the system memory is initialized, the data in the system memory is traversed and detected using the preset magic number to identify the process control block containing the preset magic number. In this embodiment, when a new kernel is detected to be started, the system boot parameter is first detected, if the second boot parameter in the system boot parameter indicates that the key memory data is selected to be retained, the target memory address for storing the key memory data flag can be further detected, and then the preset magic number is read from the target memory address, and when the system memory is initialized, the data in the system memory is traversed and detected using the preset magic number, thereby identifying all process control blocks containing the preset magic number. It should be pointed out that when the system boot parameter configuration is successful, whether the Kexec tool or the restart method is used, the rapid recovery of the process data can be successfully triggered.
[0040] In addition, it should be pointed out that in order to ensure that the identified process control block is a valid control block related to the target process, the identified process control block can be tested accordingly. Specifically, when the system memory is initialized, the data in the system memory can be tested by looking for a preset magic number to find the memory area containing the magic number, and then the memory area is parsed as a process control block structure in the operating system code. Only when the value of the magic number is correct and the data in the memory area is consistent with the arrangement of the process control block definition and is valid, for example, when the pid (process identifier) field and the name (name) field are all valid values, can the memory area at this location be confirmed to be a valid process control block.
[0041] Specifically, retaining the data and process context information in the process control block in the system memory may include: identifying the memory data area used by the target process according to the process control block, retaining the data in the memory data area, and initializing other memory areas except the memory data area; the memory data area includes the data in the process control block and the process context information. In this embodiment, the memory data area used by the target process can be first identified according to the process control block, and the area includes the data and process context information in the process control block, such as the process context, file descriptor and corresponding page cache information, and then retaining the data in the memory data area needed to be used by the recovery process, and performing normal initialization operations on other memory areas except the memory data area. It can be understood that since the device is not powered off during the reboot process, the data in the memory will not disappear.
[0042] Step S15: When it is detected that the operating system is started, the process context information and the data in the process control block are read to create a new process in the system memory, and the target process is restored in the new process based on the process context information and the data in the process control block.
[0043] In this embodiment, when it is detected that the operating system is started, the retained process context information and data in the process control block can be read directly from the system memory to create a new process in the system memory, and then the target process can be restored in the new process based on the process context information and data in the process control block.
[0044] In this embodiment, reading the process context information and the data in the process control block may specifically include: detecting whether the key memory area matches the memory data area based on the address and length of the key memory area recorded in the disk; if the key memory area matches the memory data area, reading the process context information and the data in the process control block from the system memory. In this embodiment, after the operating system is started, the process context information saved to the disk before the kernel switch and the address and length corresponding to the key memory area and other information may be read first, and then based on the above information, detecting whether the current key memory area matches the saved memory data area, and if they match, reading the process context information and the data in the process control block from the system memory to recover the process data. Through matching detection, it can be ensured that the process recovery is based on the correct memory data, thereby avoiding recovery failure.
[0045] In this embodiment, it may further include: if the critical memory area does not match the memory data area, the process context information saved on the disk and the data in the process control block are restored to the system memory, and the steps of reading the process context information and the data in the process control block are triggered. In this embodiment, if the critical memory area does not match the memory data area, the process context information saved on the disk and the data in the process control block can be restored to the corresponding areas in the system memory, and the process of reading the data in the memory and performing process recovery is triggered. That is, if there is a missing memory data area saved in the system memory, the corresponding data saved on the disk is restored to the system memory. To improve the matching speed, here, it can be determined whether they match by detecting the size of the memory area, without detecting whether the data in the system memory matches.
[0046] Correspondingly, in the new process, the target process is restored based on the process context information and the data in the process control block, including: creating a process tree based on the process tree information in the process context information; restoring the target process and the child processes generated by the target process on the process tree based on the process context information and the data in the process control block. In this embodiment, for the process recovery scenario including multiple child processes, after detecting the system memory, a new process can be started, and the original process tree structure can be rebuilt by means of multiple fork calls. Specifically, for each saved process (including the target process and the corresponding child processes), a new process is created to be a child process of the restored process tree, and then the process state information in the image file saved on the disk is restored in the new process, including restoring the memory address of the process, setting the states of the registers and the program counter, reopening the file descriptors and network connections, etc., and then setting the parent process of the new process according to the original process tree structure, so as to ensure that the restored process tree is the same as the original process tree. After the process tree is created, the critical memory data saved in the system memory can be mapped to the newly created process, and the required sockets and mount points are created or mapped, and then the context data for the process to run is restored, so as to realize the recovery of the target process and the corresponding child processes.
[0047] Further, after restoring the target process and the child processes generated by the target process on the process tree, it specifically further includes: executing the code of the target process and passing the command line parameters and environment variables of the target process to switch the context of the new process to the context of the target process. In this embodiment, after restoring the target process and the child processes generated by the target process on the process tree, that is, after the state of the new process is restored, the execve() system call can be used to execute the code of the target process, and then the command line parameters and environment variables of the target process are passed, so as to switch the context of the new process to the target process. Specifically, such as Figure 3As shown, a new process is created in the system memory for restoring the target process, and the data in the target process is restored in the new process. After the restoration, the data in the process control block corresponding to the target process is released, and then the code of the target process is executed, and the command line parameters and environment variables of the target process are passed, so as to switch the context of the new process to the context of the target process.
[0048] In addition, if the memory information check in the system memory fails or the process recovery fails due to a memory error, the process to be retained can be restored through the memory image file saved in the disk. If the memory image file in the disk does not exist or the image file recovery fails, the original data of the target process will be abandoned and a process will be restarted to ensure the existence of the process and business.
[0049] It can be seen that the embodiment of the present application adds a magic number in advance to the process control block corresponding to the target software, so when performing process recovery, the process control block corresponding to the target software can be quickly identified based on the magic number; and, when the embodiment of the present application detects that a new kernel is started, the process control block is identified based on the magic number in the target memory address, and the data in the process control block and the process context information during the operation of the target process are retained in the system memory. In this way, the target process can be directly restored according to the information recorded in the system memory (including the data in the process control block corresponding to the target process and the process context information). Compared with the process recovery method of saving process recovery data in the disk and reading process recovery data from the disk, the embodiment of the present application adds a magic number in the process control block, and identifies and retains key memory data for process data recovery after the new kernel is started, which can reduce the data recovery process from the disk to the memory, and reduce the time consumption of process recovery, thereby improving the efficiency of process recovery and reducing the impact on business operations. Therefore, the time-consuming problem of reading memory data from the disk and putting it back into the memory during process recovery can be solved, achieving the technical effect of greatly improving the process recovery speed, shortening the business interruption time, and reducing the impact of kernel switching on the business.
[0050] The present application embodiment discloses a specific process recovery method, see Figure 4 As shown, the method includes:
[0051] Step S21: When a kernel switching task needs to be executed, a process control block containing a preset magic number in the current system memory is detected.
[0052] Step S22: running the target process corresponding to the target software that needs to perform kernel switching, and collecting context information during the running of the target process to obtain process context information.
[0053] Step S23: shielding other CPU logic cores except the default CPU logic core.
[0054] In this embodiment, after collecting the context information of the target process during its execution, considering that a large number of CPU logical cores may result in a time-consuming offline operation, other CPU logical cores except the default CPU logical core (such as CPU0) may be shielded.
[0055] Step S24: Load the new kernel into the preset memory space, and restart the operating system from the new kernel in the preset memory space.
[0056] Step S25: When a new kernel is detected to be started, the process control block is identified based on the preset magic number in the target memory address, and the data and process context information in the process control block are retained in the system memory, and then the other CPU logical cores are re-onlined in turn.
[0057] In this embodiment, when a new kernel is detected to be started, the process control block containing the preset magic number can be first identified based on the preset magic number in the target memory address, and then the data and process context information in the process control block are retained in the system memory, and then the other central processing unit logical cores (such as CPU1, CPU2, etc.) are re-online in turn.
[0058] Step S26: When it is detected that the operating system is started, the process context information and the data in the process control block are read to create a new process in the system memory, and the target process is restored in the new process based on the process context information and the data in the process control block.
[0059] Among them, for more specific processing procedures of the above steps S21, S22, S24, and S26, reference can be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.
[0060] It can be seen that the embodiment of the present application shields the central processing unit logical cores other than the default central processing unit logical core before switching the kernel, and sequentially brings the shielded central processing unit logical cores back online after the new kernel is started. By shielding the interrupts and communications of the central processing unit logical cores other than the default central processing unit logical core, the serial central processing unit logical core offline operation can be modified to a parallel central processing unit logical core offline operation, thereby reducing the time consumption of the central processing unit logical core offline, so that the process data can be quickly restored after the new kernel is started, thereby reducing the process recovery time and ensuring the rapid operation of the business.
[0061] The embodiments of the present application further provide a process recovery device. For the description of the features in the embodiments corresponding to the process recovery device, reference can be made to the relevant description of the embodiments corresponding to the process recovery method, which will not be described in detail here.
[0062] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any of the above process recovery method embodiments.
[0063] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned process recovery method embodiments when running.
[0064] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0065] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any of the above process recovery method embodiments are implemented.
[0066] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned process recovery method embodiments are implemented.
[0067] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0068] The above is a detailed introduction to a process recovery method, product, device and storage medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A process recovery method, characterized in that: include: When a kernel switching task needs to be executed, the process control block containing the preset magic number in the current system memory is detected; Running a target process corresponding to a target software that needs to perform kernel switching, and collecting context information during the running of the target process to obtain process context information; Loading a new kernel into a preset memory space, and restarting the operating system from the new kernel in the preset memory space; When the new kernel is detected to be started, the process control block is identified based on the preset magic number in the target memory address, and the data in the process control block and the process context information are retained in the system memory; When it is detected that the operating system is started, the process context information and the data in the process control block are read to create a new process in the system memory, and the target process is restored in the new process based on the process context information and the data in the process control block.
2. The process recovery method according to claim 1, characterized in that: Before detecting the process control block containing the preset magic number in the current system memory, the method further includes: Configure system startup boot parameters; the system startup boot parameters include a first boot parameter, a second boot parameter and a third boot parameter; wherein the first boot parameter is used to specify a target memory address to save a critical memory data flag, the second boot parameter is used to indicate whether to select to retain the critical memory data, and the third boot parameter is used to specify a preset magic number as the critical memory data flag; When it is detected that the operating system is started, adding the preset magic number to the target memory address located in the system memory; During the operation of the operating system, determining whether the target software needs to resume operation after the kernel switch; If the target software needs to resume operation after the kernel switch, the preset system tool is called to start the target process corresponding to the target software, and the preset magic number located in the target memory address is added to the process control block of the target process.
3. The process recovery method according to claim 2, characterized in that: The adding the preset magic number to the target memory address located in the system memory includes: A random number is generated by a true random function, and the generated random number is added to the target memory address located in the system memory as the preset magic number.
4. The process recovery method according to claim 2, characterized in that: The running of the target process corresponding to the target software that needs to perform kernel switching, and collecting context information during the running of the target process to obtain process context information, include: Dynamically injecting a target process corresponding to the target software that needs to perform kernel switching through a system call mechanism, and running the target process; The context information of the target process during its execution is collected from a preset virtual file system to obtain process context information.
5. The process recovery method according to claim 4, characterized in that: After collecting the context information of the target process during its operation and obtaining the process context information, the method further includes: The process context information and the data in the process control block are saved to a disk in the form of an image file; the process context information includes a memory table and process tree information; The address and length of the key memory area occupied by the target process are recorded in the disk.
6. The process recovery method according to claim 5, characterized in that: When the new kernel is detected to be started, identifying the process control block based on the preset magic number in the target memory address includes: When it is detected that the new kernel is started, detecting a second boot parameter in the system startup boot parameter, and if the second boot parameter indicates that the critical memory data is selected to be retained, detecting a target memory address for storing a critical memory data flag, and reading the preset magic number from the target memory address; When the system memory is initialized, the preset magic number is used to traverse and detect data in the system memory to identify the process control block containing the preset magic number.
7. The process recovery method according to claim 6, characterized in that: The retaining the data in the process control block and the process context information in the system memory includes: Identify the memory data area used by the target process according to the process control block, retain the data in the memory data area, and initialize other memory areas except the memory data area; the memory data area includes the data in the process control block and the process context information.
8. The process recovery method according to claim 7, characterized in that: The reading of the process context information and the data in the process control block includes: Detecting whether the key memory area matches the memory data area based on the address and length of the key memory area recorded in the disk; If the critical memory area matches the memory data area, the process context information and the data in the process control block are read from the system memory.
9. The process recovery method according to claim 8, characterized in that: Also includes: If the critical memory area does not match the memory data area, the process context information and the data in the process control block stored in the disk are restored to the system memory, and the step of reading the process context information and the data in the process control block is triggered.
10. The process recovery method according to claim 5, characterized in that: The step of adding the preset magic number located at the target memory address to the process control block of the target process includes: Add the preset magic number located at the target memory address to the process control block of the target process and the process control block of the child process generated by the target process; Accordingly, the recovering the target process in the new process based on the process context information and the data in the process control block includes: Creating a process tree based on the process tree information in the process context information; Based on the process context information and the data in the process control block, the target process and the child processes generated by the target process are restored on the process tree.
11. The process recovery method according to claim 10, characterized in that: After the target process and the child processes generated by the target process are restored on the process tree, the method further includes: The code of the target process is executed, and the command line parameters and environment variables of the target process are passed to switch the context of the new process to the context of the target process.
12. The process recovery method according to any one of claims 1 to 11, characterized in that: Before the new kernel is loaded into the preset memory space, the method further includes: Block other CPU logic cores except the default CPU logic core; Correspondingly, after the new kernel is started, the following steps are also included: The other CPU logical cores are brought back online in sequence.
13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the process recovery method as claimed in any one of claims 1 to 12 when executing the computer program.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the process recovery method according to any one of claims 1 to 12.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the process recovery method according to any one of claims 1 to 12 are implemented.
Citation Information
Patent Citations
Method and device for automatically and quickly recovering process of computer operating system
CN114756355A
Fault recovery method based on embedded operating system
CN119248577A
Kernel soft reset using non-volatile ram
US20180165101A1
Memory swap method and apparatus, and computer device and storage medium
WO2024078342A1
Process migration method, apparatus and system
WO2024119924A1
Cited By
Process restoration method, product, device, and storage medium
WO2026179815A1