Method, device, equipment and readable storage medium for memory adaptive adjustment
By obtaining memory test information when the electronic device is started and adjusting the memory according to the unstable memory location, the problem of abnormal startup and operation caused by memory instability is solved, and memory stability and device life are improved.
Patent Information
- Application Number
- CN202011568893.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-12-25
AI Technical Summary
Existing electronic equipment starts abnormally and operates abnormally due to unstable memory, and it is impossible to guarantee the normal startup and operation of the equipment to the greatest extent.
Obtain memory test information by responding to the startup command to determine the stability of the used memory, adjust the memory according to the location of unstable memory, eliminate abnormal memory, and retain the memory that can work normally, thereby improving the stability of the memory.
Effectively reduce abnormal device startup and operation caused by memory instability, and extend the service life of the device.
Smart Images

Figure CN112559240B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and readable storage medium for memory adaptive adjustment. Background Art
[0002] With the continuous development of science and technology, electronic devices are becoming more and more popular. Various electronic devices are pouring into people's lives, and the safety and reliability of electronic devices have become particularly important. The availability of memory is the prerequisite for the availability of electronic devices; and the stability of memory determines whether electronic devices are available.
[0003] At present, during the startup process of an electronic device, if there is an unstable part in the memory, the electronic device cannot start normally, which cannot maximize the guarantee of normal startup of the device. Moreover, after the partial or complete failure of the memory of the electronic device, the electronic device may not be able to operate normally, for example, data cannot be copied normally, resulting in poor data reproducibility, etc. Therefore, the existing electronic devices have abnormal startup and operation due to the unstable memory used. Summary of the invention
[0004] The present invention provides a method, device, equipment and readable storage medium for adaptively adjusting memory, which are used to solve the problem that an electronic device may have abnormal startup and operation due to unstable memory used.
[0005] One aspect of the present invention is to provide a method for memory adaptive adjustment, comprising:
[0006] In response to a startup instruction for a device, obtaining memory test information of the device;
[0007] When it is determined that the used memory of the device is unstable according to the memory test information of the device, the used memory of the device is adjusted according to the position of the unstable memory in the used memory; wherein the used memory of the device after adjustment does not contain the unstable memory.
[0008] Another aspect of the present invention is to provide a memory adaptive adjustment device, comprising:
[0009] A memory test module, configured to obtain memory test information of the device in response to a startup instruction to the device;
[0010] A memory adjustment module is used to adjust the used memory of the device according to the position of unstable memory in the used memory when it is determined according to the memory test information of the device that the used memory of the device is unstable; wherein the used memory of the device after adjustment does not contain unstable memory.
[0011] Another aspect of the present invention is to provide an electronic device, comprising:
[0012] A processor, a memory, and a computer program stored on the memory and executable on the processor;
[0013] The memory includes a memory and a startup non-volatile memory, and the processor implements the above-mentioned memory adaptive adjustment method when running the computer program.
[0014] Another aspect of the present invention is to provide a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the above-mentioned memory adaptive adjustment method is implemented.
[0015] The method, apparatus, device and readable storage medium for adaptive memory adjustment provided by the present invention obtain memory test information of the device by responding to a startup instruction of the device; when it is determined that the used memory of the device is unstable according to the memory test information of the device, the used memory of the device is adjusted according to the position of the unstable memory in the used memory to exclude the memory in which the abnormality has occurred and retain the memory that can work normally, thereby improving the stability of the used memory of the device, reducing the device startup abnormality and device operation abnormality caused by the unstable used memory of the device, and extending the service life of the device. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A flow chart of a method for memory adaptive adjustment provided in Embodiment 1 of the present invention;
[0017] Figure 2 A flow chart of a method for memory adaptive adjustment provided in Embodiment 2 of the present invention;
[0018] Figure 3 A flow chart of a method for generating memory test information of a device during memory adaptive adjustment provided in Embodiment 3 of the present invention;
[0019] Figure 4 A schematic diagram of the structure of a memory adaptive adjustment device provided in Embodiment 4 of the present invention;
[0020] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention.
[0021] The above drawings have shown clear embodiments of the present invention, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present invention in any way, but to illustrate the concept of the present invention for those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0022] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.
[0023] The terms "first", "second", etc. involved in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. In the description of the following embodiments, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0024] The present invention is specifically applied to the scenario of electronic device startup, and the electronic device includes at least a processor, a memory, and a startup non-volatile memory (i.e., a startup flash). When the electronic device is started, the device cannot be started normally or cannot be operated normally because all or part of the memory of the device is unstable. The method for adaptive memory adjustment provided by the present invention is intended to solve the above technical problems of the prior art. The method for adaptive memory adjustment provided by the present invention can intelligently detect the stability of the memory used by the device when the electronic device is started, and adjust the memory used by the device according to the position of the unstable memory in the memory used, so as to exclude the memory that has abnormalities and retain the memory that can work normally, so as to ensure that the electronic device can start normally and work normally.
[0025] The following specific embodiments are used to describe in detail the technical solutions of the present invention and how the technical solutions of the present application solve the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0026] Embodiment 1
[0027] Figure 1 This is a flow chart of a method for adaptively adjusting memory provided in Embodiment 1 of the present invention. The embodiment of the present invention provides a method for adaptively adjusting memory to solve the problem that the electronic device may experience abnormal startup and operation due to unstable memory used. Figure 1 As shown, the specific steps of this method are as follows:
[0028] Step S101: In response to a startup instruction for a device, memory test information of the device is obtained.
[0029] The memory test information of the device is a test result of the stability of the memory used by the device, and may include whether the memory used is stable and the location of unstable memory. That is, the memory test information of the device includes the test result of whether the memory used by the device is stable or the memory used by the device is unstable, and the specific location of the unstable part in the memory used by the device.
[0030] The used memory of the device refers to the memory designated for use by the device when the device is started, which may be all the memory of the device, or part of the memory of the device may be designated as the used memory.
[0031] Specifically, the memory test information of the device can be obtained by any of the following methods:
[0032] Whether the used memory of the device is stable can be tested to determine the location of unstable memory in the used memory to obtain memory test information; or, a test result obtained by testing the used memory of the device in advance can be obtained as the memory test information.
[0033] Exemplarily, when the device is started for the first time, a stability test can be performed on all the memory of the device to determine the location of the unstable memory, obtain memory test information, and save the memory test information; or, when the device is started, if it is not the first time, obtain the test result of the stability of the device's memory usage saved when the device was last started; or obtain the test result of the stability of the device's memory usage after the device last adjusted the memory usage, etc. This embodiment is not specifically limited here.
[0034] Step S102: Determine whether the memory used by the device is stable according to the memory test information of the device.
[0035] In this embodiment, the stable used memory of the device means that the used memory of the device is completely stable, that is, if part of the used memory of the device is unstable, then the used memory of the device is considered to be unstable.
[0036] In this step, if the memory test information of the device determines that the used memory of the device is stable, the device can be started and run normally.
[0037] If it is determined based on the memory test information of the device that the device's used memory is unstable, the device cannot be started normally or an operation abnormality may occur after the device is started. Therefore, step S103 is continued to adjust the device's used memory based on the position of the unstable memory in the used memory to exclude the memory that has already been abnormal and retain the memory that can work normally.
[0038] Step S103: If the used memory of the device is unstable, the used memory of the device is adjusted according to the position of the unstable memory in the used memory.
[0039] If the device's memory test information shows that the device's used memory is unstable, the device cannot be started normally or may run abnormally after startup. In this step, the device's used memory is adjusted according to the position of the unstable memory in the used memory to exclude the abnormal memory and retain the memory that can work normally.
[0040] Since the used memory of the device is usually continuous memory, when adjusting the used memory of the device, a portion of continuous memory is determined from the original used memory of the device as the new used memory.
[0041] In addition, according to the location of unstable memory in the device's used memory, as much unstable memory as possible can be excluded, so that the used memory of the device after adjustment does not include unstable memory, or the unstable memory in the used memory of the device after adjustment is as small as possible, which can maximize the stability of the device's used memory and reduce device startup abnormalities and device operation abnormalities caused by unstable used memory of the device.
[0042] The embodiment of the present invention obtains memory test information of the device in response to a startup instruction of the device; determines whether the device's used memory is stable based on the device's memory test information; if the device's used memory is unstable, adjusts the device's used memory based on the position of the unstable memory in the used memory to exclude abnormal memory and retain memory that can work normally, thereby improving the stability of the device's used memory, reducing device startup abnormalities and device operation abnormalities caused by unstable device used memory, and extending the service life of the device.
[0043] Embodiment 2
[0044] Figure 2 A flow chart of the method for adaptive memory adjustment provided in Embodiment 2 of the present invention. Based on the above Embodiment 1, in this embodiment, when starting a device, obtaining the memory test information of the device can be specifically implemented in the following manner: determining whether this startup is the first time the device is started, if this startup is the first time the device is started, testing the memory of the device and generating the memory test information of this startup; writing the memory test information of this startup into the startup non-volatile memory; if this startup is not the first time the device is started, obtaining the memory test information of the device when it was last started.
[0045] like Figure 4As shown, the electronic device to be started includes a memory and a startup non-volatile memory. In this embodiment, in order to avoid the problem that the device cannot be started normally or cannot operate normally due to the instability of all or part of the memory when the electronic device is started, the memory of the device is tested when the electronic device is started for the first time, and the startup non-volatile memory of the electronic device is used to store the memory test information when the electronic device is started. When the electronic device is started subsequently, the memory test information of the electronic device at the last startup can be obtained from the startup non-volatile memory, and based on the memory test information of the electronic device, it is determined whether the memory of the electronic device is stable, and when it is determined that the used memory of the device is unstable, the used memory of the device is adjusted according to the position of the unstable memory in the used memory, so as to start the electronic device with stable memory.
[0046] like Figure 2 As shown, the specific steps of this method are as follows:
[0047] Step S201: In response to a startup instruction for a device, determine whether this startup is the first startup of the device.
[0048] If this is the first time the device is started, steps S202-S203 are executed to test the stability of all memory of the device and record the test results.
[0049] If this is not the first time the device is started, the stability of the device's used memory has been tested when the device was last started, and the memory test information has been stored in the startup non-volatile memory. Therefore, when starting this time, step S204 is executed to directly read the memory test information of the device when it was last started from the startup non-volatile memory. Based on the memory test information, it can be determined whether the device's used memory is stable.
[0050] Step S202: If this is the first time the device is started, the memory of the device is tested, and memory test information of this startup is generated, and the memory test information of this startup is written into the startup non-volatile memory.
[0051] The memory test information of the device is a test result of the stability of the memory used by the device, and may include whether the memory used is stable and the location of unstable memory. That is, the memory test information of the device includes the test result of whether the memory used by the device is stable or the memory used by the device is unstable, and the specific location of the unstable part in the memory used by the device.
[0052] In this embodiment, if this is the first time the device is started, a stability test is performed on all the memory of the device, memory test information is generated based on the test results, and the memory test information is written into the startup non-volatile memory for use the next time the device is started.
[0053] In addition, a stability test is performed on the memory of the device to determine whether the memory is stable and the location of the unstable memory. The memory testing method of the third embodiment can be used to implement this function.
[0054] Optionally, the startup non-volatile memory may only store the memory test information when the device was last started. Each time the current memory test information is written into the startup non-volatile memory, the previous information is overwritten.
[0055] Step S203: Determine whether the memory of the device is stable according to the memory test information started this time.
[0056] If you determine that the device's memory is unstable, restart the device.
[0057] When the device is started for the first time, after the stability test is performed on the memory of the device and memory test information is generated, it can be determined whether the memory of the device is stable based on the memory test information of this startup.
[0058] If the memory of the device is determined to be unstable according to the memory test information of this startup, it means that the device cannot start normally, so restart the device to adjust the device's memory usage when the device starts next time.
[0059] If it is determined according to the memory test information of this startup that the memory of the device is stable, the device can be started and run normally this time, and step S211 is executed to continue to start the device normally.
[0060] Step S204: If this startup is not the first startup of the device, then read the memory test information of the last startup of the device from the startup non-volatile memory.
[0061] If this is not the first time the device is started, the stability of the device's used memory has been tested when the device was last started, and the memory test information has been stored in the startup non-volatile memory. Therefore, during this startup, the memory test information of the device when it was last started is directly read from the startup non-volatile memory.
[0062] Step S205: Determine whether the device's used memory is stable based on the memory test information when the device was last started.
[0063] Whether the currently used memory of the device is stable can be determined based on the memory test information when the device was last started and read from the startup non-volatile memory.
[0064] If it is determined that the memory used by the device is stable, the device can be started and run normally this time, and step S211 is executed to continue to start the device normally.
[0065] If it is determined that the device's used memory is unstable, the device cannot be started normally or an operation abnormality may occur after the device is started, then step S206 is executed to adjust the device's used memory according to the position of the unstable memory in the used memory to exclude the memory that has already abnormally occurred and retain the memory that can work normally, and the subsequent steps S207-S210 are used to continue to start the device according to the adjusted used memory.
[0066] Step S206: adjusting the used memory of the device according to the position of the unstable memory in the used memory.
[0067] If it is determined that the device's used memory is unstable, the location of the unstable memory in the device's used memory can be determined based on the memory test information when the device was last started. Then, the device's used memory is adjusted based on the location of the unstable memory in the used memory.
[0068] Since the used memory of the device is usually continuous memory, when adjusting the used memory of the device, a part of continuous memory is determined from the original used memory of the device as new used memory, and the new used memory is configured as the used memory of the device to adjust the used memory of the device.
[0069] Specifically, the address range of the device's used memory is configured in the device's memory configuration information. After the new used memory is determined, the device's memory configuration information is updated according to the new address range of the used memory, and the new used memory is actually configured as the device's used memory.
[0070] After completing the configuration of the used memory of the device, when the memory needs to be accessed subsequently, the used memory of the device is accessed according to the address range of the used memory in the memory configuration information.
[0071] In addition, according to the location of unstable memory in the device's used memory, as much unstable memory as possible can be excluded, so that the used memory of the device after adjustment does not include unstable memory, or the unstable memory in the used memory of the device after adjustment is as small as possible, which can maximize the stability of the device's used memory and reduce device startup abnormalities and device operation abnormalities caused by unstable used memory of the device.
[0072] Among them, the location of the unstable memory in the device's used memory can be the address range of the unstable part in the memory. When adjusting the device's used memory, the memory in the address range is excluded and not used according to the address range of the unstable part in the memory, so that the adjusted device's used memory does not include the memory in the address range, that is, the adjusted device's used memory does not include the unstable memory.
[0073] Exemplarily, when adjusting the used memory of the device, the used memory of the device can be halved according to the location of the unstable memory in the used memory, so as to exclude the unstable memory from the used memory as much as possible, thereby improving the stability of the used memory of the device after the adjustment.
[0074] For example, assuming that the original used memory is 64 bits, there is unstable memory in the upper 32 bits, and the lower 32 bits are stable, the used memory of the device can be adjusted to the lower 32 bits. Preferably, when it is determined that the position of the unstable memory in the used memory is located in the high-order area of the original used memory, the used memory of the device is adjusted to the low-order area of the original used memory; when it is determined that the position of the unstable memory in the used memory is located in the low-order area of the original memory, the startup of the device is stopped and an alarm is processed; wherein, the above-mentioned original used memory refers to the memory initially assigned to the device when the device is started; the original used memory includes a high-order area and a low-order area, and the space represented by the high-order area and the low-order area are the same size, that is, the high-order area and the low-order area equally divide the original used memory. With the above technical solution, when there is an instability problem in the used memory, the used memory is dynamically adjusted according to the characteristics of the memory, thereby improving the efficiency of memory adaptive adjustment.
[0075] For example, when multiple unstable parts appear in the device's used memory, the location of the unstable memory may include multiple discontinuous address ranges. When adjusting the device's used memory, more unstable memory should be excluded as much as possible, so that the unstable memory in the adjusted device's used memory is as small as possible. For example, assuming that the original used memory is 126 bits, there is unstable memory in the upper 32 bits, and there is unstable memory in the lower 32 bits, then the device's used memory can be adjusted to the middle 64 bits of memory.
[0076] Specifically, when multiple unstable parts appear in the device's used memory, the minimum bit width unit of the memory (minimum memory threshold) and the total bit width of the original used memory are obtained, wherein each bit in the memory corresponds to an address line; the address lines corresponding to the bits represented by the stable memory address range are determined; selection is performed on the determined address lines, and the bits corresponding to the selected address lines are determined as the used memory of the adjusted device; wherein the bit width corresponding to the used memory of the adjusted device is an integer multiple of the minimum bit width unit of the memory. For example, the minimum bit width unit of the memory is 8 bits, the original used memory of the device is 64 bits, and the 64 bits of the original used memory correspond to 64 address lines; when it is determined that the bits represented by the stable memory address range are 0 to 7 bits and 8 to 15 bits, respectively, the address lines corresponding to the 0th to 7th bits and the address lines corresponding to the 8th to 15th bits are flexibly selected, such as selecting the bits corresponding to the address lines corresponding to the 0th to 7th bits as the used memory of the adjusted device. By adopting the above technical solution, the used memory of the device can be selected more flexibly according to the characteristics of the memory, thereby improving the flexibility and efficiency of memory adaptive adjustment.
[0077] Furthermore, when adjusting the device's used memory, the following methods may also be included: when it is determined that all the device's used memory is in an unstable state, by configuring the register space corresponding to the device, a specified area in the cache is configured so that the cache in the specified area is in a locked state and cannot be used by other devices; the device sends a call request to the cache; and when the cache is controlled to determine that the call request hits the locked specified area, the specified area in the cache is determined as the device's used memory.
[0078] Step S207: Determine whether the used memory of the device after adjustment is less than the minimum memory threshold.
[0079] Among them, the minimum memory threshold is the pre-set minimum memory for the device to start normally. The minimum memory threshold can be set by a technician according to the actual application scenario. For example, the minimum memory threshold can be 16 bits, which is not specifically limited in this embodiment.
[0080] In this embodiment, after adjusting the used memory of the device, if the used memory of the device is less than the minimum memory threshold, it means that the device cannot be started and run normally, and step S210 is executed to stop starting the device.
[0081] Step S208: If the used memory of the adjusted device is greater than or equal to the minimum memory threshold, the used memory of the adjusted device is tested, memory test information of this startup is generated, and the memory test information of this startup is written into the startup non-volatile memory.
[0082] In this embodiment, after adjusting the device's used memory, if the device's used memory is greater than or equal to the minimum memory threshold, it means that the device may still be able to start and run normally. At this time, it is necessary to test the stability of the adjusted device's used memory, and generate memory test information for this startup based on the test results. Then, the memory test information for this startup is written into the startup non-volatile memory for use when the device is started next time.
[0083] Step S209: based on the memory test information of this startup, if it is determined that the memory used by the device after adjustment is unstable, restart the device.
[0084] According to the memory test information of this startup, if it is determined that the used memory of the device is unstable after adjustment, the device cannot be started normally this time. Therefore, the device is restarted so that the used memory of the device is adjusted again when it is started next time to eliminate the abnormal memory, retain the memory that can work normally, and improve the stability of the used memory of the device.
[0085] According to the memory test information of this startup, if it is determined that the used memory of the device is stable after adjustment, the device can be started normally this time, and step S211 is executed to continue to start the device normally.
[0086] Step S210, stop starting the device.
[0087] Furthermore, the above-mentioned device also includes a serial port, and the memory test information can be output to the serial port device through the serial port of the device; the technician can process the memory status of the device through the memory test information output by the serial port.
[0088] Step S211, start the device normally.
[0089] The embodiment of the present invention tests the memory of the device when the device is started for the first time, and generates memory test information for this startup; writes the memory test information for this startup into a startup non-volatile memory, and restarts the device if it is determined that the memory of the device is unstable based on the memory test information for this startup; thus, when the device is started next time, since it is not the first time the device is started, it is determined that the used memory of the device is unstable based on the memory test information when the device was last started, and then the used memory of the device is adjusted based on the position of the unstable memory in the used memory to exclude the memory that has been abnormal, retain the memory that can work normally, and improve the stability of the used memory of the device, which can reduce the device startup abnormalities and device operation abnormalities caused by the unstable used memory of the device, and can extend the service life of the device.
[0090] Embodiment 3
[0091] Figure 3The flowchart of the method for generating memory test information of a device during memory adaptive adjustment provided in the third embodiment of the present invention, in combination with the first embodiment and the second embodiment, the method for generating memory test information may include:
[0092] Step S301: In response to a startup instruction to the device, write preset data into the memory.
[0093] In the embodiment of the present invention, preset data can be written into the memory through a pre-written memory test information acquisition function; the memory test information acquisition function is a source code with a function of acquiring memory test information.
[0094] Optionally, writing preset data into the memory includes: writing preset data into all address segments in the memory in sequence; or, writing preset data into a specified address segment in the memory; wherein the preset data can be a character string consisting of one or any combination of letters, numbers, special symbols, etc.
[0095] Furthermore, when the size of the storage space occupied by the preset data does not match the size of the address space written in the memory, the preset data can be dynamically adjusted according to the size of the address space written; when the storage space occupied by the preset data is larger than the size of the address space written, the preset data is intercepted according to the size of the address space written, so that part of the content in the preset data is filled into the address space written. For example, when it is necessary to write preset data A to a specified address segment in the memory, the storage space occupied by the preset data A is 10KB, and the space size corresponding to the specified address segment is 8KB, then the content occupying 8KB in the preset data A is intercepted, and the intercepted content is written into the specified address segment. Among them, the above process of intercepting the preset data can be random interception, or interception from front to back, or interception from back to front.
[0096] Step S302: Read the written data from the memory.
[0097] Step S303: Compare the read data with the preset data to determine whether the read data is consistent with the preset data, and generate memory test information according to the determination result.
[0098] In the embodiment of the present invention, the boot firmware is modified to generate memory test information during the firmware boot phase, and when the memory is determined to be in an unstable state according to the memory test information, the memory of the device is adjusted. The firmware may be BIOS.
[0099] Optionally, steps S301 to S303 are continuously executed in a loop until all address segments or specified address segments in the memory have completed recording of memory test information; that is, each time a portion of data is written in the memory, the portion of data is read out; and the written data and the read data are compared in real time to see if they are consistent. A dynamic comparison method is used, and there is no need to wait for all preset data to be written before unified comparison and recording, which effectively improves the timeliness of obtaining memory test information.
[0100] Optionally, the process of generating memory test information based on the judgment result includes: when the judgment result is that the read data is consistent with the preset data, recording that the memory of the current address segment is stable; when the judgment result is that the read data is inconsistent with the preset data, recording that the memory of the current address segment is unstable, and recording the address information of the current address segment.
[0101] Embodiment 4
[0102] Figure 4 This is a schematic diagram of the structure of the memory adaptive adjustment device provided in the fourth embodiment of the present invention. The memory adaptive adjustment device provided in the embodiment of the present invention can execute the processing flow provided in the memory adaptive adjustment method embodiment. Figure 4 As shown, the memory adaptive adjustment device 40 includes: a memory testing module 401 and a memory adjustment module 402 .
[0103] Specifically, the memory test module 401 is used to obtain memory test information of the device in response to a startup instruction to the device.
[0104] The memory adjustment module 402 is used to adjust the used memory of the device according to the position of the unstable memory in the used memory when it is determined according to the memory test information of the device that the used memory of the device is unstable.
[0105] The device provided in the embodiment of the present invention can be specifically used to execute the method embodiment provided in the above-mentioned embodiment 1, and the specific functions will not be repeated here.
[0106] The embodiment of the present invention obtains memory test information of the device in response to a startup instruction of the device; determines whether the device's used memory is stable based on the device's memory test information; if the device's used memory is unstable, adjusts the device's used memory based on the position of the unstable memory in the used memory to exclude abnormal memory and retain memory that can work normally, thereby improving the stability of the device's used memory, reducing device startup abnormalities and device operation abnormalities caused by unstable device used memory, and extending the service life of the device.
[0107] Embodiment 5
[0108] On the basis of the above fourth embodiment, in this embodiment, the memory test module is further used for:
[0109] In response to a startup instruction for a device, when it is determined that this startup is not the first startup of the device, memory test information of the last startup of the device is obtained.
[0110] Optionally, the memory test module is also used to:
[0111] If this startup is the first startup of the device, the memory of the device is tested and memory test information of this startup is generated; the memory test information of this startup is written into the startup non-volatile memory.
[0112] Optionally, the memory test module is also used to:
[0113] If the device's memory is determined to be unstable based on the memory test information from this startup, restart the device.
[0114] Optionally, the memory test module is also used to:
[0115] If this startup is not the first startup of the device, the memory test information of the last startup of the device is read from the startup non-volatile memory.
[0116] Optionally, the memory test module is also used to:
[0117] If the used memory of the device after adjustment is greater than or equal to the minimum memory threshold, the used memory of the device after adjustment is tested, memory test information of this startup is generated, and the memory test information of this startup is written into the startup non-volatile memory; based on the memory test information of this startup, if it is determined that the used memory of the device after adjustment is unstable, the device is restarted.
[0118] Optionally, the memory test module is also used to:
[0119] If the used memory of the device after adjustment is less than the minimum memory threshold, the device will be stopped from starting.
[0120] Optionally, the memory adjustment module is also used to:
[0121] Cuts the device's used memory in half based on the location of volatile memory in used memory.
[0122] Optionally, the memory adjustment module is further used to:
[0123] When it is determined that all the used memory of the device is in an unstable state, a specified area in the cache is configured by configuring the register space corresponding to the device so that the cache in the specified area is in a locked state; a call request is sent to the cache; and when the cache is controlled to determine that the call request hits the locked specified area, the specified area in the cache is determined as the used memory of the device.
[0124] The device provided in the embodiment of the present invention can be specifically used to execute the method embodiment provided in the above-mentioned embodiment 2 or embodiment 3, and the specific functions are not repeated here.
[0125] The embodiment of the present invention tests the memory of the device when the device is started for the first time, and generates memory test information for this startup; writes the memory test information for this startup into a startup non-volatile memory, and restarts the device if it is determined that the memory of the device is unstable based on the memory test information for this startup; thus, when the device is started next time, since it is not the first time the device is started, it is determined that the used memory of the device is unstable based on the memory test information when the device was last started, and then the used memory of the device is adjusted based on the position of the unstable memory in the used memory to exclude the memory that has been abnormal, retain the memory that can work normally, and improve the stability of the used memory of the device, which can reduce the device startup abnormalities and device operation abnormalities caused by the unstable used memory of the device, and can extend the service life of the device.
[0126] Embodiment 6
[0127] Figure 5 This is a schematic diagram of the structure of an electronic device provided by Embodiment 6 of the present invention. Figure 5 As shown, the electronic device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. The memory includes a memory and a startup non-volatile memory, and the processor implements the memory adaptive adjustment method provided by any of the above method embodiments when running the computer program.
[0128] Exemplarily, in this embodiment, the startup non-volatile memory may be a startup flash.
[0129] In addition, if Figure 5 As shown, the electronic device may also include components such as a power supply, a display device, and an input device, which are not specifically limited in this embodiment.
[0130] The embodiment of the present invention obtains memory test information of the device in response to a startup instruction of the device; determines whether the device's used memory is stable based on the device's memory test information; if the device's used memory is unstable, adjusts the device's used memory based on the position of the unstable memory in the used memory to exclude abnormal memory and retain memory that can work normally, thereby improving the stability of the device's used memory, reducing device startup abnormalities and device operation abnormalities caused by unstable device used memory, and extending the service life of the device.
[0131] In addition, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method for adaptive memory adjustment provided by any of the above method embodiments is implemented.
[0132] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0134] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0135] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0136] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0137] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The description and examples are to be considered exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.
[0138] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A method for adaptively adjusting memory, It is characterized in that include: In response to a startup instruction for a device, obtaining memory test information of the device; When it is determined that the used memory of the device is unstable according to the memory test information of the device, adjusting the used memory of the device according to the position of the unstable memory in the used memory; wherein the used memory of the device after adjustment does not contain the unstable memory; The adjusting the used memory of the device according to the position of the unstable memory in the used memory includes: When it is determined that all the used memory of the device is in an unstable state, configuring a designated area in the cache to be in a locked state by configuring a register space corresponding to the device; Sending a call request to the cache; The cache is controlled to determine the designated area in the cache as the used memory of the device when it is determined that the call request hits the designated area in the locked state.
2. The method according to claim 1, It is characterized in that In response to a startup instruction for a device, obtaining memory test information of the device includes: In response to a startup instruction for a device, when it is determined that this startup is not the first startup of the device, memory test information of the last startup of the device is obtained.
3. The method according to claim 2, It is characterized in that The method further comprises: If this startup is the first startup of the device, then test the memory of the device and generate memory test information of this startup; Write the memory test information of this startup into the startup non-volatile memory.
4. The method according to claim 3, It is characterized in that After writing the memory test information of this startup into the startup non-volatile memory, the method further includes: If it is determined that the memory of the device is unstable according to the memory test information of this startup, the device is restarted.
5. The method according to claim 3, It is characterized in that If the current startup is not the first startup of the device, obtaining memory test information of the device when it was last started includes: If this startup is not the first startup of the device, the memory test information of the last startup of the device is read from the startup non-volatile memory.
6. The method according to claim 1, It is characterized in that If the used memory of the device is unstable, after adjusting the used memory of the device according to the position of the unstable memory in the used memory, the method further includes: If the used memory of the device after adjustment is greater than or equal to the minimum memory threshold, test the used memory of the device after adjustment, generate memory test information of this startup, and write the memory test information of this startup into the startup non-volatile memory; If it is determined according to the memory test information of this startup that the memory used by the device is unstable after adjustment, the device is restarted.
7. The method according to claim 6, It is characterized in that The method further comprises: If the used memory of the device after adjustment is less than the minimum memory threshold, the device is stopped from starting.
8. A memory adaptive adjustment device, It is characterized in that include: A memory test module, configured to obtain memory test information of the device in response to a startup instruction to the device; A memory adjustment module, for adjusting the used memory of the device according to the position of the unstable memory in the used memory when it is determined according to the memory test information of the device that the used memory of the device is unstable; wherein the used memory of the device after adjustment does not contain the unstable memory; The memory adjustment module, when adjusting the used memory of the device according to the position of the unstable memory in the used memory, is specifically used to configure the specified area in the cache to be in a locked state by configuring the register space corresponding to the device when it is determined that all the used memory of the device is in an unstable state; send a call request to the cache; and control the cache to determine the specified area in the cache as the used memory of the device when it is determined that the call request hits the specified area in the locked state.
9. An electronic device, It is characterized in that include: A processor, a memory, and a computer program stored on the memory and executable on the processor; The memory includes a memory and a boot non-volatile memory, and the processor implements the method according to any one of claims 1 to 7 when running the computer program.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Cluster fault-tolerance system, apparatus and method
CN101369241A
Method and device for eliminating memory failure
CN102222025A
Method and device for managing system memory
CN102567225A
Restart Positioning Method, Mobile Terminal and Readable Storage Medium Based on Memory Page
CN108121613A
Abnormal treatment method and mobile terminal
CN108228398A
