Operating system hibernation method, device, computing device and storage medium

By automatically judging and adjusting the swap space size when the operating system is sleeping, the problem of insufficient swap space or excessive waste in the existing technology is solved, ensuring the normal operation of the operating system sleeping.

CN114895969BActive Publication Date: 2025-04-22UNIONTECH SOFTWARE TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210580014.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-25
Publication Date
2025-04-22
Estimated Expiration
2042-05-25

AI Technical Summary

Technical Problem

The existing system sleep method cannot automatically adjust the size of swap space when sleeping, resulting in insufficient swap space or excessive waste of disk space.

Method used

When the operating system sleep condition is detected, obtain the existing swap space size and current memory size in the computing device, determine whether the swap space needs to be expanded. If necessary, delete the existing swap space, create a swap file of the same size as the target swap space, and swap the memory data into the newly created swap space to achieve operating system sleep.

Benefits of technology

It automatically adjusts the swap space size when the operating system is sleeping, ensures the normal operation of the sleep function, and avoids the problems of insufficient swap space and waste of disk space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114895969B_ABST
    Figure CN114895969B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses an operating system hibernation method, device, computing device and storage medium, the method comprising: when it is detected that the operating system hibernation condition is met, obtaining the size of the swap space existing in the computing device and the size of the current memory; judging whether the swap space needs to be expanded according to the size of the current memory and the size of the existing swap space; if the swap space needs to be expanded, determining the size of the target swap space; deleting the existing swap space; creating a swap file of the same size as the target swap space and setting it as the target swap space; swapping the memory data of the computing device into the target swap space to realize the operating system hibernation. It can be seen that when the present invention is in hibernation, the swap space is automatically expanded according to the size of the data in the memory to ensure the normal hibernation function of the operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an operating system hibernation method, device, computing equipment and readable storage medium. Background Art

[0002] System hibernation means that the operating system of the computing device automatically transfers all the data in the memory to the swap space and cuts off the power supply to all devices, which is equivalent to the power saving state of the computing device. For example, you can set a period of time for the computing device to enter the hibernation state. In this state, the documents and programs opened in the memory will be swapped into the swap space. The swap space includes two forms, namely swap partition and swap file. However, if the swap space is insufficient, the system hibernation will fail. If the configured swap space is much larger than the memory size, it will cause a lot of waste of disk space. Therefore, it is very necessary to specify a suitable size for the swap space.

[0003] Currently, the size of the swap space is only specified when the operating system is installed. Once the operating system is installed, it is very cumbersome to adjust the size of the swap space. The swap space is a part of the storage space divided on the disk. The swap space includes the swap partition and the swap file.

[0004] Therefore, it is desired to provide an operating system hibernation method to solve the technical problem that the existing system hibernation method cannot automatically adjust the size of the swap space during hibernation. Summary of the invention

[0005] To this end, an embodiment of the present invention provides an operating system hibernation method and device, in an effort to solve or at least alleviate the above problems.

[0006] According to one aspect of an embodiment of the present invention, a method for hibernating an operating system is provided, which is executed in a computing device, and the method includes: when it is detected that a condition for hibernating the operating system is met, obtaining the size of the swap space already existing in the computing device and the size of the current memory; judging whether it is necessary to expand the swap space according to the size of the current memory and the size of the existing swap space; if it is necessary to expand the swap space, determining the size of the target swap space; deleting the existing swap space; creating a swap file of the same size as the target swap space and setting it as the target swap space; swapping the memory data of the computing device into the target swap space to achieve hibernation of the operating system.

[0007] Optionally, the step of determining the size of the target swap space includes: in response to an operation of specifying the size of the swap space in the user interaction interface, obtaining the size of the specified swap space; and using the size of the specified swap space as the size of the target swap space.

[0008] Optionally, the step of determining the size of the target swap space includes: determining whether the current memory size is greater than a target value; if the current memory size is greater than the target value, the size of the target swap space is the product of a target coefficient and the current memory size, wherein the target value is the size of the physical memory of the computing device, and the target coefficient is a value not less than 1; if the current memory size is not greater than the target value, the size of the target swap space is any value within the range of the current memory size and the target value.

[0009] Optionally, the step of setting the target swap file as the target swap space includes: updating the path of the target swap space to the path of the target swap file; formatting the target swap file as a swap file type; and activating the formatted target swap file.

[0010] Optionally, the step of creating a swap file of equal size to the target swap space includes: determining whether the size of the remaining storage space of the external storage device in the computing device is smaller than the size of the target swap space; if not, creating a swap file of equal size to the target swap space as the target swap file.

[0011] Optionally, the step of determining whether the swap space needs to be expanded according to the current memory size and the existing swap space size includes: determining whether the current memory size is larger than the existing swap space size; if so, the swap space needs to be expanded; if not, the swap space does not need to be expanded.

[0012] The operating system hibernation method provided by the present invention also includes the step of: if there is no need to expand the swap space, swapping the memory data of the computing device into the existing swap space.

[0013] According to another aspect of an embodiment of the present invention, there is provided an operating system hibernation device, which is executed in a computing device, and the device includes: an acquisition module, adapted to acquire the size of the swap space already existing in the computing device and the size of the current memory when it is detected that the conditions for the operating system to hibernate are met; a determination module, adapted to determine whether the swap space needs to be expanded based on the size of the current memory and the size of the existing swap space, and if the swap space needs to be expanded, determine the size of the target swap space; a swap space expansion module, adapted to delete the existing swap space, and create a swap file of the same size as the target swap space, and set it as the target swap space; a hibernation module, adapted to swap memory data into the target swap space to achieve operating system hibernation.

[0014] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for execution by the at least one processor, and the program instructions include instructions for executing the method as described above.

[0015] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the method described above.

[0016] According to the operating system hibernation method of an embodiment of the present invention, when it is detected that the operating system hibernation condition is met, the size of the swap space already existing in the computing device and the size of the current memory are obtained, and whether the swap space needs to be expanded is determined based on the size of the current memory and the size of the existing swap space. When expansion is required, the existing swap space is deleted, a swap space of sufficient size is created, and the memory data of the computing device is swapped into the newly created swap space to achieve operating system hibernation. It can be seen from the above content that the present invention automatically expands the swap space according to the size of the data in the memory when the operating system is hibernating to ensure the normal hibernation function of the operating system.

[0017] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation method of the embodiment of the present invention is specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] To achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The above and other purposes, features and advantages of the present disclosure will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout the present disclosure, the same reference numerals generally refer to the same parts or elements.

[0019] Figure 1 A block diagram of a computing device 100 according to one embodiment of the present invention is shown;

[0020] Figure 2 A flowchart of an operating system hibernation method 200 according to an embodiment of the present invention is shown;

[0021] Figure 3 A schematic diagram of an operating system hibernation device 300 according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0022] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0023] In order to solve the technical problem that the existing system hibernation method cannot automatically adjust the size of the swap space during hibernation, the present invention provides an operating system hibernation method, which can be implemented as an application and installed in the computing device 100. The method can also be implemented as a plug-in and integrated into the operating system of the computing device 100.

[0024] It is worth noting that no matter whether the operating system hibernation method provided by the present invention is implemented as an application or a plug-in, when the operating system is started, that is, the computing device 100 is turned on and the user logs in successfully and enters the user interface, the operating system hibernation method provided by the present invention will be started at the same time.

[0025] In some embodiments, the executable program of the operating system hibernation method provided by the present invention is stored in the / usr / bin / directory. In order to realize the self-starting of the operating system hibernation method when the operating system is started (the present invention does not limit the startup method, for example, the self-starting of the operating system hibernation method is realized with root authority), a configuration file of a predetermined type corresponding to the executable program of the operating system hibernation is created, and the configuration file of the predetermined type is stored in the / usr / lib / systemd / system directory. In this way, when the operating system is started, by executing the sudo systemctl enableswapExpan.service command, the pre-stored configuration file corresponding to the operating system hibernation method is read, and the application corresponding to the operating system hibernation method provided by the present invention or the application where the plug-in is located can be started at the same time.

[0026] The type of the configuration file of the predetermined type can be set according to the actual application scenario, and the present invention is not limited to this. For example, the configuration file of the predetermined type can be a .service file, wherein the file example of .service is as follows:

[0027] [Unit]

[0028] Description=Launch swapExpan in normal mode

[0029] After = basic.target

[0030] [Service]

[0031] Type=forking

[0032] ExecStart= / usr / bin / swapExpan

[0033] User=root

[0034] [Install]

[0035] WantedBy=basic.target

[0036] The computing device 100 mentioned above can be implemented as a server, such as an application server, a Web server, etc.; it can also be implemented as a desktop computer, a laptop computer, a processor chip, a tablet computer, etc., but is not limited thereto. Figure 11 is a block diagram of the physical components (i.e., hardware) of a computing device 100. In a basic configuration, the computing device 100 includes at least one processing unit 102 and a system memory 104. According to one aspect, the system memory 104 includes, but is not limited to, volatile storage (e.g., random access memory), non-volatile storage (e.g., read-only memory), flash memory, or any combination of such memories, depending on the configuration and type of the computing device.

[0037] According to one aspect, the system memory 104 includes an operating system 105. When the operating system hibernation method provided by the present invention is implemented as a plug-in, the plug-in of the operating system hibernation function provided by the present invention is integrated into the operating system 105. When the operating system hibernation method provided by the present invention is implemented as an application 150, the system memory 104 also includes the application 150.

[0038] According to one aspect, operating system 105, for example, is suitable for controlling the operation of computing device 100. Furthermore, examples may be practiced in conjunction with graphics libraries, other operating systems, or any other application programs, and are not limited to any particular application or system. Figure 1 This basic configuration is illustrated in FIG. 1 by those components within dashed line 108. According to one aspect, computing device 100 has additional features or functionality. For example, according to one aspect, computing device 100 includes additional data storage devices (removable and / or non-removable), such as magnetic disks, optical disks, or tapes. Such additional storage Figure 1 1 is illustrated by a removable storage device 109 and a non-removable storage device 110.

[0039] As stated above, according to one aspect, a plurality of program modules and data files are stored in the system memory 104. When the operating system hibernation method provided by the present invention is implemented as an application 150 and executed on the processing unit 102, the application 150 executes a process, which includes but is not limited to Figure 2 According to one aspect, the type of application is not limited, for example, the application also includes: email and contact applications, word processing applications, spreadsheet applications, database applications, slide show applications, drawing or computer-aided applications, web browser applications, etc.

[0040] According to one aspect, the examples may be practiced on a circuit comprising discrete electronic components, a packaged or integrated electronic chip containing logic gates, a circuit utilizing a microprocessor, or a single chip containing electronic components or a microprocessor. Figure 1Each or many components shown in can be integrated into a system on a chip (SOC) on a single integrated circuit to practice examples. According to one aspect, such a SOC device may include one or more processing units, a graphics unit, a communication unit, a system virtualization unit, and various application functions, all of which are integrated (or "burned") into a chip substrate as a single integrated circuit. When operated via SOC, the functions described in this article can be operated via a dedicated logic integrated with other components of the computing device 100 on a single integrated circuit (chip). Embodiments of the present invention can also be practiced using other technologies capable of performing logical operations (such as AND, OR, and NOT), including but not limited to mechanical, optical, fluid, and quantum technologies. In addition, embodiments of the present invention can be practiced in a general-purpose computer or in any other circuit or system.

[0041] According to one aspect, the computing device 100 may also have one or more input devices 112, such as a keyboard, a mouse, a pen, a voice input device, a touch input device, etc. Output devices 114 may also be included, such as a display, a speaker, a printer, etc. The aforementioned devices are examples and other devices may also be used. The computing device 100 may include one or more communication connections 116 that allow communication with other computing devices 118. Examples of suitable communication connections 116 include, but are not limited to: RF transmitter, receiver and / or transceiver circuits; Universal Serial Bus (USB), parallel and / or serial ports.

[0042] The term computer-readable medium as used herein includes computer storage media. Computer storage media may include volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (e.g., computer-readable instructions, data structures, or program modules). System memory 104, removable storage device 109, and non-removable storage device 110 are all examples of computer storage media (i.e., memory storage). Computer storage media may include random access memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices, or any other products that can be used to store information and can be accessed by computer device 100. According to one aspect, any such computer storage medium can be a part of computing device 100. Computer storage media does not include carrier waves or other propagated data signals.

[0043] According to one aspect, communication media is implemented by computer readable instructions, data structures, program modules, or other data in a modulated data signal (e.g., a carrier wave or other transport mechanism), and includes any information delivery media. According to one aspect, the term "modulated data signal" describes a signal that has one or more characteristics set or changed in a manner that encodes information in the signal. By way of example and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.

[0044] Figure 2 A flowchart of an operating system hibernation method 200 according to an embodiment of the present invention is shown. The method 200 is suitable for execution in a computing device 100, and the method 200 includes steps S210 to S290. Through the method 200, when the operating system is in hibernation, the swap space can be automatically expanded according to the size of the data in the memory to ensure the normal hibernation function of the operating system.

[0045] First, step S210 is executed to detect whether the operating system sleep condition is met. The sleep condition is pre-set by the user or by the system default, which is not limited. Setting the sleep time is a prior art and will not be described here. All methods for setting the sleep time are within the protection scope of the present invention.

[0046] When the computing device detects that the operating system hibernation condition is reached, step S220 is continued to be executed to obtain the size of the swap space existing in the computing device and the size of the current memory, where the current memory size is the size of the data in the current memory. Then step S230 is executed to determine whether the swap space needs to be expanded based on the size of the current memory and the size of the existing swap space. Specifically, it is determined whether the size of the current memory is larger than the size of the existing swap space. If so, it means that the existing swap space cannot accommodate all the data in the current memory, so the swap space needs to be expanded. If not, it means that the existing swap space can accommodate all the data in the current memory, so the swap space does not need to be expanded at this time.

[0047] If the swap space does not need to be expanded, step S240 is executed to swap the memory data of the computing device into the existing swap space.

[0048] If the swap space needs to be expanded, then step S250 is performed to determine the size of the target swap space. The size of the target swap space can be determined by the user customizing the swap space size, or according to the current memory size and the physical memory size of the computing device.

[0049] In some embodiments, the step of determining the size of the target space by user-defining the swap space size includes: the user specifies the swap space size in the user interaction interface, and after the determination interface is triggered, the computing device responds to the operation of specifying the swap space size in the user interaction interface, obtains the size of the swap space specified by the user, and uses the size of the swap space specified by the user as the size of the target swap space.

[0050] In some embodiments, the step of determining the size of the target space according to the current memory size and the physical memory size of the computing device includes: determining whether the current memory size is larger than the physical memory size, if the current memory size is larger than the physical memory size, then the size of the target swap space is the product of the target coefficient and the current memory size, and the target coefficient is a value not less than 1. The size of the target coefficient can be set according to the hardware of the computing device, and the present invention is not limited to this. For example, the target coefficient can be any value between 1 and 2. When the current memory size is not larger than the physical memory size, the size of the target swap space is any value within the range of the current memory size and the physical memory.

[0051] After determining the size of the target swap space, continue to execute step S260, delete the existing swap space, and continue to execute step S270 to create a swap file of the same size as the target swap space as the target swap file. Specifically, first determine whether the size of the remaining storage space of the external storage device in the computing device is smaller than the size of the target swap space. If it is not smaller, it means that the remaining storage space is sufficient, then create a swap file of the same size as the target swap space as the target swap file. If the size of the remaining storage space of the external storage device in the computing device is smaller than the size of the target swap space, it means that the remaining storage space is insufficient, then it is impossible to create a swap file of the same size as the target swap space, that is, the swap file creation fails, and continue to execute step S210.

[0052] After the target swap file is successfully created, step S280 is executed to set the target swap file as the target swap space, which is equivalent to expanding the swap space.

[0053] In some implementations, the process of expanding the swap space is as follows: first, obtain the path of the existing swap space, update the path of the target swap space to the path of the target swap file, then format the target swap file as a swap file type, and finally activate the formatted target swap file to achieve the expansion of the swap space.

[0054] After the swap space is expanded, step S290 is continued to be executed to swap the memory data of the computing device into the target swap space to realize the hibernation of the operating system.

[0055] Thus, the automatic expansion of the swap space during the operating system hibernation process is realized. Whenever the operating system hibernation is detected, steps S210 to S290 need to be performed.

[0056] Figure 3 The structure block diagram of an operating system hibernation device 300 according to an embodiment of the present invention is shown. The device 300 comprises an acquisition module 310, a determination module 320, a swap space expansion module 330 and a hibernation module 340 which are coupled in sequence.

[0057] The acquisition module 310 is adapted to acquire the size of the swap space and the size of the current memory existing in the computing device when it is detected that the operating system hibernation condition is reached.

[0058] The determination module 320 is adapted to determine whether the swap space needs to be expanded according to the current memory size and the size of the existing swap space, and if the swap space needs to be expanded, determine the size of the target swap space.

[0059] The swap space expansion module 330 is adapted to delete the existing swap space and create a swap file of the same size as the target swap space as the target swap file, and is also adapted to set the target swap file as the target swap space.

[0060] The hibernation module 340 is adapted to swap memory data into a target swap space to implement hibernation of the operating system.

[0061] It should be noted that the working principle of the operating system hibernation device 300 is similar to that of the operating system hibernation method 200 . For relevant details, reference may be made to the description of the operating system hibernation method 200 , which will not be repeated here.

[0062] From the above content, it can be seen that the operating system hibernation method provided by the present invention, when it is detected that the operating system hibernation condition is met, obtains the size of the swap space already existing in the computing device and the size of the current memory, and determines whether the swap space needs to be expanded according to the size of the current memory and the size of the existing swap space. When expansion is required, the existing swap space is deleted, a swap space of sufficient size is created, and the memory data of the computing device is swapped into the newly created swap space to realize the operating system hibernation. It can be seen that in the present invention, when the operating system is hibernating, the swap space is automatically expanded according to the size of the data in the memory to ensure the normal hibernation function of the operating system.

[0063] The various techniques described herein may be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or parts of the method and apparatus of the present invention may be in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.

[0064] In the case where the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; the processor is configured to execute the operating system hibernation method of the present invention according to the instructions in the program code stored in the memory.

[0065] By way of example and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embody computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and include any information transfer medium. Any combination of the above is also included within the scope of readable media.

[0066] In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the examples of the present invention. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to implement the content of the present invention described herein, and the above description of specific languages ​​is for the purpose of disclosing the best mode of the present invention.

[0067] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0068] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those expressly recited in each claim. Rather, as reflected in the claims, inventive aspects lie in less than all of the features of the individual embodiments previously disclosed. Therefore, the claims that follow the detailed description are hereby expressly incorporated into the detailed description, with each claim itself serving as a separate embodiment of the present invention.

[0069] Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in the devices described in the embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.

[0070] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0071] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims, any one of the claimed embodiments may be used in any combination.

[0072] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.

[0073] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.

[0074] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.

Claims

1. A method for hibernating an operating system, executed in a computing device, the method comprising: When it is detected that the operating system hibernation condition is met, obtaining the size of the swap space and the current memory size existing in the computing device; Determine whether the swap space needs to be expanded based on the current memory size and the size of the existing swap space; If you need to expand the swap space, determine the size of the target swap space; Delete the existing swap space; Creating a swap file of the same size as the target swap space as the target swap file, and setting the target swap file as the target swap space, wherein the step of setting the target swap file as the target swap space includes updating the path of the target swap space to the path of the target swap file, formatting the target swap file as a swap file type, and activating the formatted target swap file; The memory data of the computing device is swapped into the target swap space to implement operating system hibernation.

2. The method of claim 1, wherein: The steps to determine the target swap space size include: In response to the operation of specifying the size of the swap space in the user interaction interface, the size of the specified swap space is obtained; The size of the specified swap space is used as the size of the target swap space.

3. The method of claim 1, wherein: The steps to determine the target swap space size include: Determine whether the current memory size is greater than the target value; If the current memory size is larger than the target value, the target swap space size is the product of the target coefficient and the current memory size, wherein the target value is the size of the physical memory of the computing device, and the target coefficient is a value not less than 1; If the current memory size is not greater than the target value, the target swap space size is any value within the range of the current memory size and the target value.

4. The method of claim 1, wherein: The steps to create a swap file of the same size as the target swap space include: Determine whether the size of the remaining storage space of the external storage device in the computing device is smaller than the size of the target swap space; if not, create a swap file of the same size as the target swap space.

5. The method of claim 1, wherein: The steps to determine whether to expand the swap space based on the current memory size and the existing swap space size include: Determine whether the current memory size is larger than the existing swap space size. If so, the swap space needs to be expanded. If not, the swap space does not need to be expanded.

6. The method of claim 1, further comprising the steps of: If there is no need to expand the swap space, the memory data of the computing device is swapped into the existing swap space.

7. An operating system hibernation device, executed in a computing device, the device comprising: an acquisition module, adapted to acquire the size of the swap space and the size of the current memory existing in the computing device when it is detected that the operating system hibernation condition is reached; A determination module, adapted to determine whether the swap space needs to be expanded according to the current memory size and the size of the existing swap space, and if the swap space needs to be expanded, determine the size of the target swap space; A swap space expansion module, adapted to delete an existing swap space, and create a swap file of a size equal to that of a target swap space as a target swap file, and set the target swap file as the target swap space, wherein setting the target swap file as the target swap space comprises updating a path of the target swap space to a path of the target swap file, formatting the target swap file as a swap file type, and activating the formatted target swap file; The hibernation module is adapted to swap memory data into the target swap space to implement hibernation of the operating system.

8. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 6.

9. A readable storage medium storing program instructions, when the program instructions are read and executed by a computing device, the computing device executes the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • STD (Suspend to disk) management method and STD management system used in computer system

    CN105573860A

  • Linux operating system sleep quick starting method based on NVDIMM

    CN107589969A

  • Data caching method and device, terminal equipment and storage medium

    CN111371704A