CN113934648A - Power-down resume method and device for data and electronic equipment - Google Patents

Power-down resume method and device for data and electronic equipment Download PDF

Info

Publication number
CN113934648A
CN113934648A CN202111205416.3A CN202111205416A CN113934648A CN 113934648 A CN113934648 A CN 113934648A CN 202111205416 A CN202111205416 A CN 202111205416A CN 113934648 A CN113934648 A CN 113934648A
Authority
CN
China
Prior art keywords
data
index
area
stored
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111205416.3A
Other languages
Chinese (zh)
Inventor
董江
马群
张�浩
张逾良
徐卫东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shijiazhuang Tonghe Electronics Co Ltd
Original Assignee
Shijiazhuang Tonghe Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shijiazhuang Tonghe Electronics Co Ltd filed Critical Shijiazhuang Tonghe Electronics Co Ltd
Priority to CN202111205416.3A priority Critical patent/CN113934648A/en
Publication of CN113934648A publication Critical patent/CN113934648A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)

Abstract

The invention is suitable for the technical field of data storage, and provides a method, a device and electronic equipment for power-down continuous storage of data, wherein the method circularly stores write index values of the data through a plurality of index storage units, and obtains the data to be stored; sequentially detecting whether the write index values stored in the index storage units are abnormal or not; and determining the current write index value of the data area from the write index values according to the detection result, and storing the data to be stored to the data storage unit indicated by the current write index value. The power-down restoration method of the data can realize the power-down restoration of the data.

Description

Power-down resume method and device for data and electronic equipment
Technical Field
The invention belongs to the technical field of data storage, and particularly relates to a method and a device for power-down storage continuation of data and electronic equipment.
Background
Electric automobile and fill electric pile's power module often need carry out local storage to many continuous data. Conventionally, when a plurality of pieces of data of the same type are stored continuously, an address area is created for the type of data, the address area includes a data area and an index area, the data area is used for storing the data circularly, and the index area is used for storing the writing index value of the data area circularly, that is, the writing position of the next piece of data in the data area.
However, when the system is powered off and powered on again accidentally, the system cannot determine the power-off position due to the existence of more than one write index value in the index area, and the power-off continuous storage of data cannot be realized.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, and an electronic device for power-down resume of data, so as to implement power-down resume of data.
The first aspect of the embodiments of the present invention provides a method for resuming data after power failure, where the method is used to store data to be stored in an address area; the address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area;
the method comprises the following steps:
acquiring data to be stored;
sequentially detecting whether the write index values stored in the index storage units are abnormal or not;
and according to the detection result, determining the current write index value of the data area from the write index values, and storing the data to be stored to the data storage unit indicated by the current write index value.
Optionally, detecting whether a certain write index value is abnormal includes:
judging whether the write index value is equal to zero or not, and calculating the absolute value of the difference value of the write index value and the write index value stored in the last index storage unit of the index storage unit where the write index value is located;
if the write index value is equal to zero, judging whether the absolute value of the difference value is equal to a first set value or not, and if the absolute value of the difference value is not equal to the first set value, judging that the write index value is abnormal; wherein, the first set value is the difference value between the size of the data area and the size of the data storage unit;
if the write index value is not equal to zero, judging whether the absolute value of the difference value is equal to a second set value or not, and if the absolute value of the difference value is not equal to the second set value, judging that the write index value is abnormal; the second setting value is the size of the data storage unit.
Optionally, determining a current write index value of the data area from the write index values according to the detection result includes:
if a certain write index value is detected to be abnormal, terminating detection and taking the write index value stored in the last index storage unit of the index storage unit where the write index value is located as the current write index value of the data area;
and if the detection result shows that all the write index values are normal, taking the write index value stored in the last index storage unit of the index area as the current write index value of the data area.
Optionally, after storing the data to be stored in the data storage unit indicated by the current write index value, the method further includes:
updating the current write index value of the data area, and storing the updated current write index value into the index area;
the storage position of the updated current write index value in the index area is the index storage unit next to the index storage unit where the current write index value is located; and if the index storage unit where the current write index value is located is the last index storage unit in the index area, the storage position of the updated current write index value in the index area is the first index storage unit in the index area.
Optionally, updating the current write index value of the data area includes:
updating the current write Index value of the data area according to Index' ═ Index + ByteLen;
the Index ' is a current write Index value of the updated data area, the Index is a current write Index value of the data area before updating, the bytlen is a size of a data storage unit in the data area, and the Index ' is set to zero if the Index ' is greater than or equal to the size of the data area.
Optionally, the size of the data storage unit in the data area is determined by the following formula:
ByteLen=L1/C1
where bytlen is the size of the data storage unit, L1 is the length of the data to be stored, and C1 is the byte length of the data area.
Optionally, after acquiring the data to be stored, the method further includes:
judging whether the data to be stored corresponds to the address area or not according to the type of the data to be stored;
if the data to be stored corresponds to the address area, storing the data to be stored in the address area; and if the data to be stored does not correspond to the address area, not storing the data to be stored.
A second aspect of the embodiments of the present invention provides a power-down resume device for data, where the device is configured to store data to be stored in an address area; the address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area;
the device includes:
the acquisition module is used for acquiring data to be stored;
the detection module is used for sequentially detecting whether the write index values stored in the index storage units are abnormal or not;
and the storage module is used for determining the current write index value of the data area from the write index values according to the detection result and storing the data to be stored to the data storage unit indicated by the current write index value.
A third aspect of the embodiments of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the steps of the power-down resume method of the above data.
A fourth aspect of the embodiments of the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the power-down resume method for the above data.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
the power-down resume method for the data provided by the embodiment of the invention has the advantages that the data area and the index area are arranged in the address area, the data area circularly stores the data to be stored, and the index area circularly stores the writing index value of the data area; and then based on the rule among the write index values stored in the index area, when the system is powered off to cause the interruption of the storage process and the power is re-powered on, sequentially detecting whether each write index value stored in the index area is abnormal or not, determining the current write index value of the data area from each write index value according to the detection result, and storing the data to be stored to the data storage unit indicated by the current write index value, so that the power-off continuous storage of the data can be realized.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is an exemplary diagram of an address area provided by an embodiment of the present invention;
fig. 2 is a schematic flow chart illustrating an implementation of a method for resuming data after power failure according to an embodiment of the present invention;
FIG. 3 is a diagram of a circular storage write index value provided by an embodiment of the invention;
FIG. 4 is a flow chart of a normal circular storage of data provided by an embodiment of the present invention;
FIG. 5 is a flow chart of a power-down restore of data provided by an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a power-down resume apparatus for data according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
Electric automobile and fill power module among the electric pile and move under adverse conditions or when taking place the abnormal conditions, can take place the operation trouble, when network communication is unusual, this trouble can not transmit in real time to the server, carries out the local storage of trouble when needing to take place unusually this moment, when network communication is normal, uploads the server with local data, is favorable to the seeking of problem and prevents the emergence of unexpected condition.
Therefore, the embodiment of the present invention provides a method for resuming data after power failure, where the method is used to store data to be stored in an address area. The address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area.
Illustratively, referring to fig. 1, for the continuous storage of the same type of data, a corresponding address area is opened in the IIC memory, the address area includes a data area and an index area, the data area stores data content, the index area stores a write index value of the data area, i.e. a data write position, and the data area and the index area may be continuous, for example, in the embodiment of the present invention, the data area is before and the index area is after.
The data area is divided into a plurality of data storage units to cyclically store data to be stored. For example, in fig. 1, the size DataLen of the data area is 28 bytes, each byte is 8 bits, each data needs to occupy 4 bytes for a certain type of data with the length of 32 bits, the size bytlen of one data storage unit is 4, and the data area can store n-7 data. When data is stored, the data is stored from the first data storage unit, and when the last data storage unit also stores the data, the next data is stored in the first data storage unit to cover the original data, so that the cyclic storage of the data is realized. The data area size DataLen may be set according to actual needs, and is not limited herein. Similarly, the index area is also provided with a plurality of index storage units for circularly storing the write index values of the data area, and each index storage unit stores one write index value. The size of the index area IndexLen, the size of the index storage unit ByteLen, and the number m of write index values that can be stored in the index area may be set according to actual needs, and are not limited herein.
When the system is powered off and powered on again, because more than one index value is stored in the index area, how to find the final write index value in the power-off state from the plurality of write index values is the key for data persistence.
In view of the above problem, referring to fig. 2, an embodiment of the present invention provides a corresponding power-down resume method, which includes the following steps:
and step S101, acquiring data to be stored.
In the embodiment of the invention, the data to be stored can be fault condition, operation time, working time, voltage, current and the like, the IIC memory allocates corresponding address areas for each type of data, and a plurality of continuous data of the same type are stored in the same address area.
And step S102, sequentially detecting whether the write index values stored in the index storage units are abnormal.
In the embodiment of the invention, the write index values stored in each index storage unit have a certain rule, and when a certain write index value does not meet the rule, the write index value is an abnormal write index value, and the abnormal write index value is not really abnormal and can indicate the power failure moment.
And step S103, determining the current write index value of the data area from the write index values according to the detection result, and storing the data to be stored to the data storage unit indicated by the current write index value.
In the embodiment of the invention, the power failure time can be determined according to the abnormal write index value, so that the current write index value of the data area, namely the final write index value of the data area before the power failure is determined, and the data to be stored is written into the data area according to the final write index value, so that the power failure continuous storage of the data can be realized.
Therefore, in the power-down resume method for data provided by the embodiment of the invention, the data area and the index area are arranged in the address area, the data area circularly stores the data to be stored, and the index area circularly stores the write index value of the data area; and then based on the rule among the write index values stored in the index area, when the system is powered off to cause the interruption of the storage process and the power is re-powered on, sequentially detecting whether each write index value stored in the index area is abnormal or not, determining the current write index value of the data area from each write index value according to the detection result, and storing the data to be stored to the data storage unit indicated by the current write index value, so that the power-off continuous storage of the data can be realized.
Optionally, in step S102, detecting whether a certain write index value is abnormal may be detailed as:
step S1021, judging whether the write index value is equal to zero, and calculating the absolute value of the difference value of the write index value and the write index value stored in the last index storage unit of the index storage unit where the write index value is located.
Step S1022, if the write index value is equal to zero, determining whether the absolute value of the difference is equal to a first set value, and if the absolute value of the difference is not equal to the first set value, determining that the write index value is abnormal; the first setting value is the difference between the size of the data area and the size of the data storage unit.
Step S1023, if the write index value is not equal to zero, judging whether the absolute value of the difference value is equal to a second set value, and if the absolute value of the difference value is not equal to the second set value, judging that the write index value is abnormal; the second setting value is the size of the data storage unit.
In the embodiment of the present invention, referring to fig. 3, the loop storage of the index area is explained. Assuming that the data area DataLen is 28, the data storage unit size bytlen is 4, the index area size IndexLen is 16, the index storage unit size bytlen is 4, and the index area can store the number m of write index values 4. The write index value stored cyclically in the index area will be in the range of 0-24, cyclically varying by a step value of 4. In the first cycle, the first position of the write index value in the index area is 0, the second position is 4, the third position is 8, and the fourth position is 12. In the second cycle, the first location is updated to 16, the second location is updated to 20, the third location is updated to 24, and the fourth location is updated to 0 since the data is stored in the data area from the beginning after completing one cycle. And so on for the third and fourth. It can be seen that, normally, the difference between the write index value variation at non-0 and the previous write index value is the data storage unit size 4, and the absolute value of the difference between the write index value variation at 0 and the previous write index value is the difference 24 between the data area size and the data storage unit size. And traversing all the write index values in sequence, and when a certain write index value is not satisfied with the above rule, determining that the certain write index value is an abnormal write index value.
Optionally, in step S102, according to the detection result, the current write index value of the data area is determined from the respective write index values, which may be detailed as follows:
if a certain write index value is detected to be abnormal, terminating detection and taking the write index value stored in the last index storage unit of the index storage unit where the write index value is located as the current write index value of the data area;
and if the detection result shows that all the write index values are normal, taking the write index value stored in the last index storage unit of the index area as the current write index value of the data area.
In the embodiment of the present invention, based on step S102, when the system is powered down, assuming that the first position of the second loop is updated at this time, the write index value stored in the first position is 16, and the write index values of the second, third, and fourth positions are not updated, and are sequentially 4, 8, and 12. And traversing each write index value in sequence, and when traversing to a second position, finding that the difference value between the stored write index value 4 and the last write index value 16 is not equal to the size 4 of the data storage unit and does not accord with the rule under the normal condition, so that the write index value 4 can be judged as an abnormal write index value, and the previous write index value 16 is the final write index value updated before power failure, namely the storage resuming position. The absolute value of the difference between the write index value at 0 and the previous write index value should be 24, otherwise 0 is the power down position. In addition, if the index area finishes one cycle in power failure, the write index values in the index area are not abnormal, and at the moment, the write index value stored in the last index storage unit in the index area is the final write index value updated before power failure.
Optionally, after the step S103 stores the data to be stored in the data storage unit indicated by the current write index value, the method further includes:
updating the current write index value of the data area, and storing the updated current write index value into the index area;
the storage position of the updated current write index value in the index area is the index storage unit next to the index storage unit where the current write index value is located; and if the index storage unit where the current write index value is located is the last index storage unit in the index area, the storage position of the updated current write index value in the index area is the first index storage unit in the index area.
Optionally, the updating of the current write index value of the data area may be detailed as:
updating the current write Index value of the data area according to Index' ═ Index + ByteLen;
the Index ' is a current write Index value of the updated data area, the Index is a current write Index value of the data area before updating, the bytlen is a size of a data storage unit in the data area, and the Index ' is set to zero if the Index ' is greater than or equal to the size of the data area.
In the embodiment of the invention, the write index value is used for indicating the initial storage position of the data to be stored in the data area, and after the data is written according to the write index value every time, the write index value of the data area is updated according to the end storage position of the data, so that the cyclic storage of the data in the data area is realized. Similarly, the writing index value is circularly stored in the index area.
Optionally, the size of the data storage unit in the data area is determined by the following formula:
ByteLen=L1/C1
where bytlen is the size of the data storage unit, L1 is the length of the data to be stored, and C1 is the byte length of the data area.
Since the different types of data have different lengths, the data storage unit sizes of the different types of data are also different, and the data storage unit sizes can be calculated according to the data lengths and the bit numbers of the data areas.
Optionally, after acquiring the data to be stored, the method further includes:
judging whether the data to be stored corresponds to the address area or not according to the type of the data to be stored;
if the data to be stored corresponds to the address area, storing the data to be stored in the address area; and if the data to be stored does not correspond to the address area, not storing the data to be stored.
In the data storage process, data to be stored is firstly required to be placed in a buffer area, then the data is read from the buffer area and stored in a corresponding address area according to the data type, namely the data of the same type is stored in the same address area. Therefore, before the data is stored, whether the data to be stored corresponds to the address area is judged according to the type of the data to be stored, and if not, the data is not stored; alternatively, the data is stored to an address area corresponding to its type.
It should be noted that the power-down restoration method for data provided in the embodiment of the present invention can be used regardless of whether the system is powered down or not, but can be used only when the system is powered down and powered up again in order to increase the processing speed of data, and after the system is not powered down or power-down restoration is implemented, the data can be stored in a normal write index value in a circulating manner, and a specific flow is as shown in fig. 4:
(1) extracting data of a buffer area;
(2) writing data into the data area indicated by the index value;
(3) judging whether the data writing is successful; if the operation is unsuccessful, executing an externally input operation instruction, and skipping or rewriting the data area according to the operation instruction;
(4) updating the write index value;
(5) storing the updated write index value to the indication position of the index zone index;
(6) the index zone index number index is automatically moved to the next or first index storage unit;
(7) and (4) returning to the step (1), and extracting the next data for storage until no data exists in the buffer area.
When the system is powered off and powered on again, the power-off resume method of the data can be used, and the specific flow is as shown in fig. 5: and traversing the write index values from the first index storage unit (namely, reading the write index value IRead at the initial address Iaddr of the index area) of the index area, and returning the previous write index value as the current write index value when a certain write index value meets any one abnormal judgment condition. And if all the write index values are not abnormal, defining the current write index value as the write index value stored in the last index storage unit. After the power failure position is found according to the power failure continuous storage method for the data, the data can be continuously transferred to a conventional circulating storage process, and the data processing speed is further improved. The embodiment of the invention determines the power failure moment by searching the abnormal phenomenon point, obtains the index value of the inscription when the power failure happens, has simple method, is easy to understand, does not need to occupy more storage space, and is convenient to open up the index area for use when the index area is short.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Referring to fig. 6, an embodiment of the present invention further provides a device for resuming data after power failure, where the device is used to store data to be stored in an address area. The address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area.
The apparatus 60 comprises:
the obtaining module 61 is configured to obtain data to be stored.
And a detection module 62, configured to detect whether the write index values stored in the index storage units are abnormal in sequence.
And the storage module 63 is configured to determine a current write index value of the data area from the write index values according to the detection result, and store the data to be stored in the data storage unit indicated by the current write index value.
Optionally, the detection module 62 is specifically configured to:
judging whether the write index value is equal to zero or not, and calculating the absolute value of the difference value of the write index value and the write index value stored in the last index storage unit of the index storage unit where the write index value is located;
if the write index value is equal to zero, judging whether the absolute value of the difference value is equal to a first set value or not, and if the absolute value of the difference value is not equal to the first set value, judging that the write index value is abnormal; wherein, the first set value is the difference value between the size of the data area and the size of the data storage unit;
if the write index value is not equal to zero, judging whether the absolute value of the difference value is equal to a second set value or not, and if the absolute value of the difference value is not equal to the second set value, judging that the write index value is abnormal; the second setting value is the size of the data storage unit.
Optionally, the storage module 63 is specifically configured to:
if a certain write index value is detected to be abnormal, terminating detection and taking the write index value stored in the last index storage unit of the index storage unit where the write index value is located as the current write index value of the data area;
and if the detection result shows that all the write index values are normal, taking the write index value stored in the last index storage unit of the index area as the current write index value of the data area.
Optionally, after storing the data to be stored in the data storage unit indicated by the current write index value, the storage module 63 is further configured to:
updating the current write index value of the data area, and storing the updated current write index value into the index area;
the storage position of the updated current write index value in the index area is the index storage unit next to the index storage unit where the current write index value is located; and if the index storage unit where the current write index value is located is the last index storage unit in the index area, the storage position of the updated current write index value in the index area is the first index storage unit in the index area.
Optionally, the storage module 63 is further configured to:
updating the current write Index value of the data area according to Index' ═ Index + ByteLen;
the Index ' is a current write Index value of the updated data area, the Index is a current write Index value of the data area before updating, the bytlen is a size of a data storage unit in the data area, and the Index ' is set to zero if the Index ' is greater than or equal to the size of the data area.
Optionally, the storage module 63 is further configured to:
determining the size of the data storage unit in the data area according to the following formula:
ByteLen=L1/C1
where bytlen is the size of the data storage unit, L1 is the length of the data to be stored, and C1 is the byte length of the data area.
Optionally, after acquiring the data to be stored, the acquiring module 61 is further configured to:
judging whether the data to be stored corresponds to the address area or not according to the type of the data to be stored;
if the data to be stored corresponds to the address area, storing the data to be stored in the address area; and if the data to be stored does not correspond to the address area, not storing the data to be stored.
Fig. 7 is a schematic diagram of an electronic device 70 according to an embodiment of the present invention. As shown in fig. 7, the electronic apparatus 70 of this embodiment includes: a processor 71, a memory 72, and a computer program 73, such as a power-down restore of data, stored in the memory 72 and operable on the processor 71. The processor 71, when executing the computer program 73, implements the steps in the above-described power down resume method embodiment of the respective data, such as the steps S101 to S103 shown in fig. 1. Alternatively, the processor 71, when executing the computer program 73, implements the functions of the modules in the above-described device embodiments, such as the functions of the modules 61 to 63 shown in fig. 6.
Illustratively, the computer program 73 may be divided into one or more modules/units, which are stored in the memory 72 and executed by the processor 71 to carry out the invention. One or more of the modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 73 in the electronic device 70. For example, the computer program 73 may be divided into an acquisition module 61, a detection module 62, and a storage module 63 (module in a virtual device), and the specific functions of the modules are as follows:
the obtaining module 61 is configured to obtain data to be stored.
And a detection module 62, configured to detect whether the write index values stored in the index storage units are abnormal in sequence.
And the storage module 63 is configured to determine a current write index value of the data area from the write index values according to the detection result, and store the data to be stored in the data storage unit indicated by the current write index value.
The electronic device 70 may be a computing device such as a desktop computer, a notebook, a palm top computer, and a cloud server. The electronic device 70 may include, but is not limited to, a processor 71, a memory 72. Those skilled in the art will appreciate that fig. 7 is merely an example of the electronic device 70 and does not constitute a limitation of the electronic device 70 and may include more or fewer components than shown, or combine certain components, or different components, e.g., the electronic device 70 may also include input-output devices, network access devices, buses, etc.
The Processor 71 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 72 may be an internal storage unit of the electronic device 70, such as a hard disk or a memory of the electronic device 70. The memory 72 may also be an external storage device of the electronic device 70, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. provided on the electronic device 70. Further, the memory 72 may also include both internal storage units and external storage devices of the electronic device 70. The memory 72 is used to store computer programs and other programs and data required by the electronic device 70. The memory 72 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other ways. For example, the above-described apparatus/electronic device embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments of the present invention may also be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of the embodiments of the method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A power-down resume method of data is characterized in that the method is used for storing data to be stored into an address area; the address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area;
the method comprises the following steps:
acquiring data to be stored;
sequentially detecting whether the write index values stored in the index storage units are abnormal or not;
and determining the current write index value of the data area from the write index values according to the detection result, and storing the data to be stored to the data storage unit indicated by the current write index value.
2. The method of power-down copy of data as claimed in claim 1, wherein detecting whether a write index value is abnormal comprises:
judging whether the write index value is equal to zero or not, and calculating the absolute value of the difference value of the write index value and the write index value stored in the last index storage unit of the index storage unit where the write index value is located;
if the write index value is equal to zero, judging whether the absolute value of the difference value is equal to a first set value or not, and if the absolute value of the difference value is not equal to the first set value, judging that the write index value is abnormal; the first set value is the difference value between the size of the data area and the size of the data storage unit;
if the write index value is not equal to zero, judging whether the absolute value of the difference value is equal to a second set value or not, and if the absolute value of the difference value is not equal to the second set value, judging that the write index value is abnormal; the second setting value is the size of a data storage unit.
3. The method for resuming the data under power of claim 1, wherein determining the current write index value of the data area from the respective write index values according to the detection result comprises:
if a certain write index value is detected to be abnormal, terminating detection and taking the write index value stored in the last index storage unit of the index storage unit where the write index value is located as the current write index value of the data area;
and if the detection result shows that all the write index values are normal, taking the write index value stored in the last index storage unit of the index area as the current write index value of the data area.
4. The method for restoring data in a power-down manner according to claim 1, wherein after storing the data to be stored in the data storage unit indicated by the current write index value, the method further comprises:
updating the current writing index value of the data area, and storing the updated current writing index value into the index area;
the storage position of the updated current write index value in the index area is the index storage unit next to the index storage unit where the current write index value is located; and if the index storage unit where the current write index value is located is the last index storage unit in the index area, setting the storage position of the updated current write index value in the index area as the first index storage unit in the index area.
5. The method of power down restore of data as claimed in claim 4, wherein updating the current write index value of the data area comprises:
updating the current write Index value of the data area according to Index' ═ Index + ByteLen;
and setting Index 'to zero if the Index' is larger than or equal to the size of the data area.
6. The method for power-down restoration of data according to any one of claims 1 to 5, wherein the size of the data storage unit in the data area is determined by the following formula:
ByteLen=L1/C1
where bytlen is the size of the data storage unit, L1 is the length of the data to be stored, and C1 is the byte length of the data area.
7. The method for power-down restoration of data according to any one of claims 1 to 5, wherein after acquiring the data to be stored, the method further comprises:
judging whether the data to be stored corresponds to the address area or not according to the type of the data to be stored;
if the data to be stored corresponds to the address area, storing the data to be stored in the address area; and if the data to be stored does not correspond to the address area, not storing the data to be stored.
8. The device for resuming the data after power failure is characterized in that the device is used for storing the data to be stored in an address area; the address area comprises a data area and an index area, the data area is divided into a plurality of data storage units, each data storage unit circularly stores data to be stored, the index area is divided into a plurality of index storage units, and each index storage unit circularly stores a write index value of the data area;
the device comprises:
the acquisition module is used for acquiring data to be stored;
the detection module is used for sequentially detecting whether the write index values stored in the index storage units are abnormal or not;
and the storage module is used for determining the current write index value of the data area from all the write index values according to the detection result and storing the data to be stored to the data storage unit indicated by the current write index value.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the steps of the method according to any of claims 1 to 7 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202111205416.3A 2021-10-15 2021-10-15 Power-down resume method and device for data and electronic equipment Pending CN113934648A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111205416.3A CN113934648A (en) 2021-10-15 2021-10-15 Power-down resume method and device for data and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111205416.3A CN113934648A (en) 2021-10-15 2021-10-15 Power-down resume method and device for data and electronic equipment

Publications (1)

Publication Number Publication Date
CN113934648A true CN113934648A (en) 2022-01-14

Family

ID=79279647

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111205416.3A Pending CN113934648A (en) 2021-10-15 2021-10-15 Power-down resume method and device for data and electronic equipment

Country Status (1)

Country Link
CN (1) CN113934648A (en)

Similar Documents

Publication Publication Date Title
CN108923957B (en) Distribution network terminal DTU fault elimination method and device and terminal equipment
CN106664100A (en) Technologies for efficient lz77-based data decompression
US8782375B2 (en) Hash-based managing of storage identifiers
CN111343267B (en) Configuration management method and system
CN113010116A (en) Data processing method and device, terminal equipment and readable storage medium
US8645404B2 (en) Memory pattern searching via displaced-read memory addressing
CN112181479A (en) Method and device for determining difference between code file versions and electronic equipment
CN111381905B (en) Program processing method, device and equipment
CN113934648A (en) Power-down resume method and device for data and electronic equipment
CN112783971B (en) Transaction recording method, transaction query method, electronic device and storage medium
AU2021339989B2 (en) Tri-color bitmap array for garbage collection
CN111143092A (en) Fault recording data processing method and system and terminal equipment
CN112216333B (en) Chip testing method and device
CN113886302A (en) Serial port number obtaining method and device of application equipment, terminal equipment and storage medium
CN109560964B (en) Equipment compliance checking method and device
CN111857604A (en) Method, apparatus, device and medium for quickly reconstructing packet management mapping reverse lookup table
CN113934649A (en) Power-down resume method and device for data and electronic equipment
CN112099759A (en) Numerical value processing method, device, processing equipment and computer readable storage medium
CN117079703B (en) Method and device for testing embedded memory of chip and electronic equipment
CN113535710B (en) Searching method, searching device, terminal equipment and storage medium
CN111125041A (en) Data reading method, electronic device and computer program product
CN113918095B (en) Hybrid cross storage method and device for data and electronic equipment
CN109446166B (en) Method for detecting file directory, computer readable storage medium and terminal device
CN109885402B (en) Method for testing function output data overflow, terminal equipment and storage medium
CN111669104B (en) Motor driving method, device, terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination