This application claims the benefit of Taiwan application Serial No. 100147798, filed Dec. 21, 2011, the disclosure of which is incorporated by reference herein in its entirety.
1. Technical Field
The disclosed embodiments relate in general to a method for a hibernation mechanism and a computer system therefor.
2. Description of the Related Art
As the code for an Android operating system made public by Google is extremely suitable in an embedded system, the number of products including mobile phones, tablet computers, smart television and automobile computers implementing an Android operating system is quickly expanding. During the development of the products, differentiations can be achieved through not only hardware designs but also Android software designs.
A fast boot process renders even more easily accessible digital information as already is, and thus practically offers readily available digital household appliances immediately after powering on. In most smart devices, a shut-down button is set as a standby mode instead of a real power-off mode. Although the standby mode effectively reduces a wait time, such design is regarded as a “high power consumption fast boot” as it nevertheless continuously consumes electric power. The electric power consumed by the standby mode increases global carbon dioxide emissions by 1%. According to European Union regulations, the power consumption of smart household appliances must be less than 0.1 W when not in use. Therefore, there is a need for a high-speed boot method for mitigating issues brought by the standby mode as well as for meeting the above requirement. Currently, some high-speed boot methods are performed based on a sleep mode.
Further, most current embedded systems including for example digital cameras, navigation systems, smart mobile phones and tablet computers adopt a flash memory as a storage device. However, the flash memory has a limitation on the number of write processes, which yet needs to be overcome.
The disclosure is directed to a method for a hibernation mechanism and a computer system therefor.
According to one embodiment, a method for a hibernation mechanism is provided. The method is applicable to a computer system and includes the followings. An initial process of a hibernation mechanism is first performed in the computer system. In the computer system, at least one non-swappable memory of a main memory is partitioned into a plurality of non-swappable segments, and each of the non-swappable segments corresponds to a status value indicating whether content of the non-swappable segment has been changed. During a process of entering a hibernation state, for each of the non-swappable segments, it is determined whether the non-swappable segment is to be written to at least one storage device according to the status value of the non-swappable segment. When a determination result indicates the content of the non-swappable segment has been changed, the non-swappable segment is written to the at least storage device of the computer system. When the determination result indicates the content of the non-swappable segment has not been changed, the computer system does not write the non-swappable segment to the at least one storage device of the computer system in the hibernation state.
According to another embodiment, a computer system is provided. The computer system includes at least one main memory, at least one storage device, and at least one processing unit coupled to the at least one processing unit and the at least one storage device. The at least one processing unit performs an initial process of a hibernation mechanism. A non-swappable memory of the at least one main memory is partitioned into a plurality of non-swappable segments, and each of the non-swappable segments corresponds to a status value indicating whether content of the non-swappable segment has been changed. During a process of the computer system entering a hibernation state, for each of the non-swappable segments, the at least one processing unit determines whether to write the non-swappable segment to the at least one storage device according to the status value. When a determination result indicates the content of the non-swappable segment has been changed, the at least processing module writes the non-swappable segment to the at least one storage device. When the determination result indicates the content of the non-swappable segment has not been changed, the at least one processing unit does not write the non-swappable unit to the at least storage device in the hibernation state.
In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the disclosed embodiments. It will be apparent, however, that one or more embodiments may be practiced without these specific details. In other instances, well-known structures and devices are schematically shown in order to simplify the drawing.
An embodiment of a method for a hibernation mechanism and a computer system therefor shall be described below.
The main memory, the storage device and the processing units in the diagram and description of the embodiment are depicted in a block diagram. However, it should be noted that the number of the main memory, the storage device and the processing units in this embodiment is not limited to one although one of each is depicted. For example, the computer system may also include several processing units such as a multi-core processor or multiple processors, and the main memory (or the secondary memory) may be consisted of several relative memory devices.
Referring to
Step S20 is performed after the initial process in step S10. As shown in step S20, during a process of the computer system 1 entering a hibernation state of the hibernation mechanism, it is determined whether each of the non-swappable segments is to be written to the storage device 14. More specifically, in step S201, according to the status value of the non-swappable segment, it is determined whether the non-swappable segment is to be written to the storage device 14. When a determination result in step S201 indicates that content of the non-swappable segment has been changed, step S203 is performed to write the non-swappable segment to the storage device 14 of the computer system 14. For example, the non-swappable segment is written to a swap space 141, a file system 142 or a hibernation file 143. When the determination result in step S201 indicates the content of the non-swappable segment has not been changed, the computer system 1 does not write the non-swappable segment to the storage device 14 in the hibernation state, as shown in block S205.
In a conventional hibernation mechanism, the non-swappable memory 1210 is entirely written to a non-volatile memory each time the computer system 1 enters a hibernation state. In contrast, in the initial process of the hibernation mechanism in this embodiment, the non-swappable memory is further partitioned into a plurality of segments each corresponding to a status value, and only non-swappable segments having changed content are written to the storage device when entering the hibernation state.
Further, during the process of entering the hibernation state when performing step S20, a table (e.g., a table MT in
In one embodiment, after resuming from the hibernation state in step S20, in the event that the computer system 1 again enters the hibernation state, step S20 may be performed until the computer system 1 reboots (e.g., a cold boot or a warm boot), or the method may again be performed from step S10. In other embodiments, the method for fast boot based on the hibernation mechanism may also be achieved through the method in
Other embodiments based on the method in
In this embodiment, operations details of a computer system are illustrated by taking Linux or an operating system based on Linux as an example. For example, the operating system is a software pack such as TuxOnIce and sususp for implementing software suspend in Linux. TuxOnIce, being a descendent of swsusp, is an enhanced generation of swsusp and has a faster hibernation and response time. In this embodiment, a TuxOnIce operating platform based on Linux is taken as an example.
Before explaining the embodiment of implementing the method in
A main purpose of the first step is to offer the system with sufficient free space for the second step, such that sufficient working memory is available in the second step for ensuring that the second step is a one-time write (i.e., an atomic write).
Assuming majority of the main memory in the system is the non-swappable memory, it is much likely that TuxOnIce fails to write sufficient memory to the secondary memory in the first step, thus resulting in insufficient working memory in the second step. In the event of the above occurrence, TuxOnIce reports the error to a user to inform the user of the failure of entering a sleep mode. However, such situation shall not be discussed further.
Under most circumstances, majority of the memory in the system is the first-part memory, which includes a considerable amount as the non-swappable memory. As such, TuxOnIce fabricates the first-part memory into a single image file, which is to be one-time written to become a hibernation file. The hibernation file can be stored in the file system or in the swap space. Alternatively, the hibernation file may even be stored to a physical device other than the system, e.g., a network storage such as a cloud storage device.
When applying suspend to disk or hibernation of TuxOnIce to the storage device 14 (e.g., a flash memory device), the second-part swappable memory is written out by page-out via a virtual memory, and repeated data (a same duplicate in the secondary memory) is not practically written out. However, since the first-part memory is one-time written out based on TuxOnIce, an actual write out is required for repeated data in the first-part memory.
The first embodiment is targeted at reducing the write out process from the first-part memory to the secondary memory. Therefore, in step S10 in
After the initial process in step S11, step S201 is performed. In step S201, during a process of the computer system 5 entering a hibernation state, for each of the non-swappable segments, it is determined whether the non-swappable segment is to be written to the storage device 14 according to the status value of the non-swappable segment (i.e., a current value of the dirty bit). When the status value of the non-swappable segment is dirty in step S201, it is determined that the content of the non-swappable segment has been changed, and so step 203 is performed to write the non-swappable segment to the storage device 14 of the computer system 1. When the status value of the non-swappable segment is clean in step S201, it is determined that the content of the non-swappable segment has not been changed. Thus, in step S205, the computer system 5 does not write the non-swappable segment to the storage device 14 during the hibernation state.
Apart from being coupled between the processing unit 10 and the main memory 12, the MMU 51 in
A main difference between the second embodiment and the first embodiment is that, in the second embodiment, the function of the MMU is replaced by a method executed by a processing unit or other hardware devices, and the computer system generates a corresponding status value according to the content of each of the non-swappable segments. For example, a processing unit of a computer device is utilized for calculating the status value. For another example, a computer system 8 in
After the initial process in step S12, step S22 is performed. Step S22 is an embodiment of step S20 in
Further, when the comparison result obtained in step S221 indicates being the same, as far as a characteristic value calculated based on a hash function is concerned, it substantially indicates that data content in the non-swappable segment and in the corresponding segment of the storage device 14 is “much likely” identical. That is to say, a probability that the data content in two corresponding segments being exactly the same is very high. Under certain circumstances, e.g., under a high performance, low power consumption or another operating condition, the data contents in the two corresponding segments are regarded to be totally identical. Therefore, as shown in step S225, the non-swappable segment is not written out. Under other circumstances, e.g., under a high system operation stability or another operating condition, an additional step may be performed for confirming the data contents. For example, in another example as shown in
Further, when booting the computer system (e.g., the computer system 1, 5, or 8), the first-part memory is loaded by system loading software 50 or 80 such as an operating system, BIOS or a bootloader. Since the first-part memory may be stored to a plurality of devices (e.g., the swap space 141, the file system 142 and the hibernation file 143 regarded as devices in Linux) in an intermittent manner (e.g., the segments of the non-swappable memory 1210 are stored to different corresponding memory positions in the storage device, as indicated by arrows in
It should be noted that, a Linux platform is taken as an example in the above description for illustrative purposes, and the embodiments may also be applied to other operating systems including BSD and Windows.
The above description discloses embodiments of the method for a hibernation mechanism and the computer system therefore. In principle, the embodiment of the method is capable of increasing the speed of fast boot for the computer system from hibernation, for resume, or for resume from hibernation.
It will be apparent to those skilled in the art that various modifications and variations can be made to the disclosed embodiments. It is intended that the specification and examples be considered as exemplary only, with a true scope of the disclosure being indicated by the following claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
100147798 | Dec 2011 | TW | national |