Data writing method and device, electronic equipment and storage medium

By obtaining the characteristic value and mark bit value of the memory card, the data writing location is determined and written directly to the memory card, which solves the problem of data clearing when the memory card is repeatedly written, and improves writing efficiency and space utilization.

CN118732950APending Publication Date: 2024-10-01安徽蓬阳健康科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410834471.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the existing technology, when reusing a memory card, all data contents need to be cleared before writing, resulting in insufficient storage space utilization and long writing time.

Method used

By obtaining the current values ​​of the preset characteristic value flag bit and the preset read flag bit, the starting position and characteristic value of the target data to be written are determined, so that the target storage space can be directly written to avoid clearing all data.

Benefits of technology

It reduces the time required to write data, improves the storage space utilization efficiency of the memory card, and avoids the need to start writing from the first memory block.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118732950A_ABST
    Figure CN118732950A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data writing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a current feature value and a current mark value when a data writing request for writing target data into a target storage space is received; wherein the current mark value is used for indicating whether the target storage space is in a read state or not; based on the current mark value and the current feature value, determining a to-be-written initial position and a target feature value corresponding to the target data; and writing the target data into the target storage space based on the target feature value and the to-be-written initial position. According to the technical scheme, the operation of emptying all data contents in the memory card before repeatedly writing the data is avoided, the data writing time consumption is reduced, and the data does not need to be written from the first memory block, so that the storage space of the memory card can be efficiently utilized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of data processing technology, and in particular to a data writing method, device, electronic device, and storage medium. Background Art

[0002] The memory card can be used to temporarily store some important data. For example, the relevant data of a certain user (such as dynamic electrocardiogram data) can be written into the memory card for storage.

[0003] Currently, for a reusable memory card, when a data writing operation of a certain user is completed and after the data content in the memory card is read, the memory card can be cleared so that the memory card can be used to write the relevant data of the next user again.

[0004] However, when rewriting the relevant data of other users in the above data writing method, regardless of whether there is any remaining storage space in the memory card, all data contents in the memory card need to be cleared first, and then the data to be recorded are written in sequence starting from the first storage block of the memory card. Based on this, the existing data writing method not only cannot efficiently utilize the storage space of the memory card, but also has the problem of being time-consuming. Summary of the invention

[0005] The present invention provides a data writing method, device, electronic device and storage medium to avoid the operation of clearing all data contents in a storage card before repeatedly writing data, reduce the time consumption of data writing and efficiently utilize the storage space of the storage card.

[0006] In a first aspect, an embodiment of the present invention provides a data writing method, the method comprising:

[0007] When receiving a data write request to write target data to a target storage space, obtaining a current feature value on a preset feature value flag bit and a current mark value on a preset read mark bit; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state;

[0008] Based on the current mark value and the current feature value, determining a starting position to be written and a target feature value corresponding to the target data;

[0009] Based on the target characteristic value and the starting position to be written, the target data is written into the target storage space.

[0010] In a second aspect, an embodiment of the present invention further provides a data writing device, the device comprising:

[0011] A data writing request module, configured to obtain a current characteristic value on a preset characteristic value flag bit and a current mark value on a preset read mark bit when receiving a data writing request to write target data to a target storage space; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state;

[0012] A write position determination module, used to determine a to-be-written start position and a target characteristic value corresponding to the target data based on the current mark value and the current characteristic value;

[0013] The target data writing module is used to write the target data into the target storage space based on the target characteristic value and the starting position to be written.

[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0015] one or more processors;

[0016] a storage device for storing one or more programs,

[0017] When one or more programs are executed by one or more processors, the one or more processors implement any data writing method as in the embodiments of the present invention.

[0018] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to perform any data writing method as described in any of the embodiments of the present invention.

[0019] The technical solution of the embodiment of the present invention, when receiving a data write request to write target data to the target storage space, obtains the current characteristic value on the characteristic value mark bit and the current mark value on the preset read mark bit, wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state, and then, based on the current mark value and the current characteristic value, determines the starting position to be written and the target characteristic value corresponding to the target data, thereby writing the target data to the target storage space based on the target characteristic value and the starting position to be written. The technical solution of the present invention determines the starting position of the data to be written by the current mark value and the current characteristic value. Since the starting position to be written has been determined before the data is written, it can be quickly and efficiently determined from which storage block of the target storage space to start writing according to the starting position to be written, avoiding the operation of clearing all data contents in the storage card before repeatedly writing data, reducing the time consumption of data writing; and there is no need to write data from the first storage block, so that the storage space of the storage card can be efficiently utilized. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 A schematic diagram of a flow chart of a data writing method provided by an embodiment of the present invention;

[0022] Figure 2 A simplified schematic diagram of multiple storage blocks in a target storage space involved in an embodiment of the present invention;

[0023] Figure 3 A schematic flow chart of another data writing method provided by an embodiment of the present invention;

[0024] Figure 4 A schematic diagram of a storage block to be processed according to an embodiment of the present invention;

[0025] Figure 5 A schematic diagram of an execution process of determining a starting position to be written according to a bad block inspection result according to an embodiment of the present invention;

[0026] Figure 6 A schematic diagram of the structure of a data writing device provided by an embodiment of the present invention;

[0027] Figure 7 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0029] Embodiment 1

[0030] Figure 1 A flow chart of a data writing method provided in an embodiment of the present invention is applicable to the situation of repeatedly writing data to a reusable memory card. The method can be executed by a data writing device, which can be implemented in the form of software and / or hardware. The hardware can be an electronic device, such as a mobile terminal, a PC or a server.

[0031] like Figure 1 As shown, the data writing method includes:

[0032] S110. When a data write request for writing target data into a target storage space is received, a current feature value on a preset feature value mark bit and a current mark value on a preset read mark bit are obtained.

[0033] The target storage space is a reusable memory card, for example, a large-capacity NAND FLASH memory chip, etc. The target data is the data to be processed to be written into the target storage space. The data write request is the request instruction information for writing the target data into the target storage space.

[0034] In this embodiment, a preset feature value flag and a preset read flag are determined in advance in the target storage space. The feature value is stored in the preset feature value flag, and each time the computer reads the data in the target storage space, a new and unique feature value is generated. Therefore, the current feature value is the feature value on the preset feature value flag at the current moment.

[0035] Among them, the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state. The mark value can be an unread mark value or a read mark value, for example, the unread mark value is 0 (or 1), and the read mark value is 1 (or 0). When data has been written in the target storage space and the computer end has not read the new data, the mark value on the preset read mark bit is the unread mark value. After the computer end reads the data in the target storage space, the mark value on the preset read mark bit will switch from the unread mark value to the read mark value. The current mark value is the mark value on the preset read mark bit at the current moment. It should be noted that the computer end reads all the data in the target storage space each time, and there is no situation where the computer end reads part of the data in the target storage space.

[0036] Specifically, the target data may be a data packet collected in advance, or the target data may be data content collected in real time. In the case where the target data is a data packet collected in advance, when the data packet needs to be written into the target storage space, the user can trigger a preset data write control, and a data write request is generated at this time. In the case where the target data is data content collected in real time, during the process of real-time data collection, the collected data can be stored in a data cache pool, and when the space in the data cache pool is full, the data in the data cache pool needs to be written into the target storage space, and a data write request is generated at this time. Furthermore, when a data write request is received, the current feature value in the preset feature value flag bit at the current moment and the current mark value on the preset read mark bit are read.

[0037] Exemplarily, the target storage space can be configured in a dynamic ECG acquisition device, which can collect the user's ECG data in real time and temporarily store the ECG data in a data cache pool. When the space in the data cache pool is full, the ECG data in the data cache pool needs to be written to the target storage space. At this time, a data write request is generated, and the current feature value and the current tag value can be obtained.

[0038] S120. Determine the starting position to be written and the target characteristic value corresponding to the target data based on the current mark value and the current characteristic value.

[0039] The current tag value is an unread tag value or a read tag value. The target feature value is a feature value to be used in the end. The target feature value is a current feature value or a new feature value different from the current feature value.

[0040] In this embodiment, the target storage space includes a plurality of storage blocks, the storage capacity of each storage block is limited, and each storage block corresponds to a different physical address. It is understandable that the target data usually needs to occupy at least one storage block. The starting position to be written is used to indicate which storage block in the target storage space the target data starts to be written from, and the starting position to be written is the physical address corresponding to the storage block.

[0041] Specifically, the specific implementation method of determining the starting position to be written corresponding to the target data based on the current mark value and the current characteristic value may be: if the current mark value is an unread mark value, the starting position to be written may be the physical address of the next storage block of the occupied storage block, and the next storage block of the occupied storage block may be determined according to the termination storage block corresponding to the current characteristic value. This situation indicates that the previously stored data in the target storage space has not been read, that is, the previously stored data still needs to be retained, so the starting position to be written may be a storage block other than the storage block of the previously stored data. If the current mark value is a read mark value, the starting position to be written may be the physical address of the first available storage block. This situation indicates that the previously stored data in the target storage space has been read, that is, the previously stored data does not need to be retained, so the target data can be written starting from the first available storage block in the target storage space.

[0042] Furthermore, it is possible to determine whether to update the current feature value based on the current tag value to determine the target feature value. Specifically, if the current tag value is a read tag value, a new feature value is generated based on a preset random number generation algorithm, so that the current feature value is updated based on the new feature value to obtain the target feature value; if the current tag value is an unread tag value, the current feature value is determined as the target feature value.

[0043] The preset random number generation algorithm may be any algorithm that can generate random numbers, for example, a linear congruential method, a Mersenne twister algorithm, a SHA-1 hash algorithm, a Gaussian distribution, and the like.

[0044] In this embodiment, if the current tag value is a read tag value, that is, the data previously stored in the target storage space has been read, then it is necessary to generate a new feature value different from the previously used feature value (current tag value), and at this time, a preset random number generation algorithm can be used to generate a new feature value, and this new feature value is used as the target feature value. If the current tag value is an unread tag value, that is, the data previously stored in the target storage space has not been read, then the current tag value is the target feature value.

[0045] S130: Write the target data into the target storage space based on the target characteristic value and the starting position to be written.

[0046] In this embodiment, starting from the storage block corresponding to the start position to be written, the target characteristic value and the target data are written into at least one storage block in the target storage space, and each storage block includes the target characteristic value and a portion of the target data.

[0047] For example, the target data size is 640KB, the space capacity of a single storage block of the target storage space is 64KB, and writing the target data into the target storage space requires 10 storage blocks. Figure 2 ,like Figure 2 As shown, when the target characteristic value is "1256" and the starting position to be written is the storage block with a physical address of 0001, the target characteristic value "1256" and the first part of the target data can be written to the storage block with a physical address of 0001, the target characteristic value "1256" and the second part of the target data can be written to the storage block with a physical address of 0002, the target characteristic value "1256" and the third part of the target data can be written to the storage block with a physical address of 0003, and so on, until the target characteristic value "1256" and the tenth part of the target data are written to the storage block with a physical address of 0010, thereby completing the execution process of writing the target data into the target storage space.

[0048] Based on the above example, after S130, the method also includes: setting the mark value on the preset read mark bit to an unread mark value; when receiving a data read instruction corresponding to the target storage space, switching the mark value on the preset read mark bit from an unread mark value to a read mark value.

[0049] The unread mark value is used to indicate that the target storage space is in an unread state, and the read mark value is used to indicate that the target storage space is in a read state.

[0050] In this embodiment, after the operation of writing the target data into the target storage space is completed, the mark value on the preset read mark bit is set to the unread mark value. At this time, if a data write request is received again, the current mark value is the unread mark value. As time goes by, if the processing user wants to read the data stored in the target storage space, a communication connection can be established between the target storage space and the computer end. When the processing user triggers the preset data read control, a data read instruction corresponding to the target storage space is generated, thereby switching the mark value on the preset read mark bit from the unread mark value to the read mark value. At this time, if a data write request is received again, the current mark value is the read mark value.

[0051] It should be noted that the acquisition, storage, use, and processing of data in the technical solution of this application are in compliance with the relevant provisions of national laws and regulations. For example, network requests are intercepted and processed with the authorization of the user.

[0052] The technical solution of the embodiment of the present invention, when receiving a data write request to write target data to the target storage space, obtains the current characteristic value on the characteristic value mark bit and the current mark value on the preset read mark bit, wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state, and then, based on the current mark value and the current characteristic value, determines the starting position to be written and the target characteristic value corresponding to the target data, thereby writing the target data to the target storage space based on the target characteristic value and the starting position to be written. The technical solution of the present invention determines the starting position of the data to be written by the current mark value and the current characteristic value. Since the starting position to be written has been determined before the data is written, it can be quickly and efficiently determined from which storage block of the target storage space to start writing according to the starting position to be written, avoiding the operation of clearing all data contents in the storage card before repeatedly writing data, reducing the time consumption of data writing; and there is no need to write data from the first storage block, so that the storage space of the storage card can be efficiently utilized.

[0053] Embodiment 2

[0054] Figure 3 This is a schematic diagram of a data writing method provided by an embodiment of the present invention. Based on the above embodiment, S120 and S130 are described in detail. The specific implementation method can refer to the technical solution of this embodiment. Among them, the technical terms that are the same or corresponding to the above embodiment are not repeated here.

[0055] like Figure 3 As shown, the method specifically comprises the following steps:

[0056] S210. When a data write request for writing target data into a target storage space is received, a current feature value on a preset feature value mark bit and a current mark value on a preset read mark bit are obtained.

[0057] S220: Determine a target feature value based on the current tag value and the current feature value.

[0058] S230: If the current mark value is a read mark value, determine the first available storage block in the target storage space as the storage block to be processed.

[0059] The first available storage block is the first storage block in the target storage space that can store data.

[0060] In this embodiment, the schematic diagram of the storage block to be processed is shown in Figure 4 ,like Figure 4 As shown in (a), when the current tag value is the read tag value (the tag value is 1), the storage block with the physical address 0001 is the first available storage block, that is, the storage block is the storage block to be processed.

[0061] S240: If the current mark value is an unread mark value, determine a termination storage block corresponding to the current mark value, so as to determine a next adjacent storage block of the termination storage block as a storage block to be processed.

[0062] In this embodiment, see Figure 4 (b), when the current mark value is the unread mark value (mark value is 0), if the storage block with the physical address of 0010 is the termination storage block corresponding to the last written data (that is, the termination storage block corresponding to the current mark value), then the storage block with the physical address of 0011 is the next adjacent storage block of the termination storage block, that is, the storage block is the storage block to be processed.

[0063] S250: Determine the starting position to be written corresponding to the target data based on the bad block inspection result of the storage block to be processed.

[0064] In this embodiment, due to the inherent properties of the target storage space, some storage blocks in the target storage space are bad blocks; in addition, the target storage space has the characteristic of being repeatedly readable and writable, which may also cause some storage blocks to become bad blocks after repeated read and write operations. Therefore, before writing data, it is necessary to perform a bad block check on the storage block to be processed to determine whether the storage block to be processed is a bad block, and the bad block check result is a good block or a bad block. By determining the starting position to be written corresponding to the target data through the bad block check result of the storage block to be processed, the problem of data storage loss caused by writing data into a bad block can be effectively avoided.

[0065] Specifically, the schematic diagram of the execution process of determining the starting position to be written according to the bad block inspection result is shown in Figure 5The specific implementation method may include the following steps: S2501, calling a predetermined bad block record table; S2502, determining the bad block test result of the storage block to be processed based on the physical address of the storage block to be processed and the bad block record table; S2503, if the bad block test result is a good block, determining the storage block to be processed as the starting position to be written; S2504, if the bad block test result is a bad block, determining the next storage block of the storage block to be processed as the storage block to be processed, and repeating the step of determining the bad block test result of the storage block to be processed, so as to determine the starting position to be written corresponding to the target data based on the bad block test result.

[0066] The bad block record table includes the physical addresses corresponding to the bad storage blocks in the target storage space.

[0067] In this embodiment, based on the bad block record table obtained, it is queried whether the bad block record table includes the physical address of the storage block to be processed; if so, the bad block check result of the storage block to be processed is a bad block. At this time, the next storage block of the storage block to be processed is determined as the storage block to be processed, and S2502-S2504 is repeatedly executed; if not, the bad block check result of the storage block to be processed is a good block. At this time, the storage block to be processed is determined as the starting position to be written.

[0068] S260: Divide the target data into at least one sub-data to be written based on the preset unit capacity corresponding to each storage block in the target storage space.

[0069] In this embodiment, the preset unit capacity is an inherent property of the target storage space and is easy to obtain. For example, the data size of the target data is 640KB, and the preset unit capacity of the target storage space is 64KB, so the target data is divided into 10 sub-data to be written.

[0070] S270 , taking the start position to be written as the starting point, determining at least one storage block to be written that is consistent with the number of at least one sub-data to be written.

[0071] Among them, the bad block inspection results of the storage blocks to be written are all good blocks.

[0072] In this embodiment, the storage block corresponding to the starting position to be written can be used as the starting point to determine multiple storage blocks to be checked with adjacent physical addresses, and the bad block inspection results of each storage block to be checked can be determined respectively; if there is a bad block, a substitute storage block whose bad block inspection result is a good block is determined, so that the storage block to be checked and the substitute storage block are used as the storage blocks to be written. If there is no bad block, these storage blocks to be checked are determined as the storage blocks to be written.

[0073] S280. For each storage block to be written, if the storage block to be written is in a used state, the data in the storage block to be written is erased, and then the target characteristic value and the corresponding sub-data to be written are written into the storage block to be written; if the storage block to be written is in an unused state, then the target characteristic value and the corresponding sub-data to be written are written into the storage block to be written.

[0074] In this embodiment, the target storage space can be a brand new memory card or a used memory card. If the target storage space is a used memory card, the previous data is erased before writing data.

[0075] In this embodiment, when determining the storage blocks to be written that are consistent with the number of sub-data to be written, the sub-data to be written corresponding to each storage block to be written can be determined based on the sequence of acquisition timestamps corresponding to the sub-data to be written and the sequence of physical addresses of each storage block to be written.

[0076] Specifically, for each storage block to be written, if the storage block to be written is in a used state, the data in the storage block to be written is first erased, and then the target characteristic value and the corresponding sub-data to be written are written into the storage block to be written. If the storage block to be written is not in a used state, the target characteristic value and the corresponding sub-data to be written can be directly written into the storage block to be written.

[0077] S290, updating the target characteristic value to the current characteristic value on the preset characteristic value mark; when a data write request to write the target data into the target storage space is received again, repeating the steps of obtaining the current characteristic value and the current mark value, determining the starting position to be written, the target characteristic value, and writing the target data into the target storage space based on the target characteristic value and the starting position to be written.

[0078] After the above steps, the target characteristic value is stored in the preset characteristic value mark, and when a data write request to write the target data into the target storage space is received again, the operation steps S210-S280 are repeated.

[0079] The technical solution of the embodiment of the present invention, when determining the starting position to be written corresponding to the target data based on the current mark value, if the current mark value is a read mark value, the first available storage block in the target storage space is determined as the storage block to be processed. If the current mark value is an unread mark value, the termination storage block corresponding to the last written data is determined, so as to determine the next adjacent storage block of the termination storage block as the storage block to be processed. Thus, based on the bad block inspection result of the storage block to be processed, the starting position to be written corresponding to the target data is determined, which can quickly and efficiently determine which storage block in the target storage space the target data starts to be written from, and can effectively avoid the problem of data storage loss caused by writing data into a bad block. Further, when writing the target data into the target storage space based on the target characteristic value and the starting position to be written, first, based on the preset unit capacity corresponding to each storage block in the target storage space, the target data is divided into at least one sub-data to be written, and then, with the starting position to be written as the starting point, at least one storage block to be written that is consistent with the number of at least one sub-data to be written is determined, wherein the bad block inspection results of the storage block to be written are all good blocks, so that for each storage block to be written, if the storage block to be written is in a used state, the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written after erasing the data in the storage block to be written; if the storage block to be written is in an unused state, the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written. Since erasing data in many storage blocks over a large area will be time-consuming, the present application only erases one storage block each time, and then writes the target data, and this process takes very little time, thereby improving the data writing efficiency as a whole.

[0080] Embodiment 3

[0081] Figure 6 This is a schematic diagram of the structure of a data writing device provided by an embodiment of the present invention. The device includes: a data writing request module 310 , a writing position determining module 320 and a target data writing module 330 .

[0082] The data write request module 310 is used to obtain the current characteristic value on the preset characteristic value flag bit and the current mark value on the preset read mark bit when receiving a data write request to write the target data to the target storage space; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state;

[0083] A write position determination module 320, for determining a to-be-written start position and a target characteristic value corresponding to the target data based on the current mark value and the current characteristic value;

[0084] The target data writing module 330 is used to write the target data into the target storage space based on the target characteristic value and the starting position to be written.

[0085] Based on the above device, optionally, the device further includes: a tag value switching module;

[0086] A mark value switching module is used to set the mark value on a preset read mark bit to an unread mark value; and is also used to switch the mark value on the preset read mark bit from an unread mark value to a read mark value when a data read instruction corresponding to the target storage space is received; wherein the unread mark value is used to indicate that the target storage space is in an unread state, and the read mark value is used to indicate that the target storage space is in a read state.

[0087] On the basis of the above device, optionally, the current mark value is an unread mark value or a read mark value, and the write position determination module 320 includes a target feature value unit;

[0088] The target feature value unit is specifically used to generate a new feature value based on a preset random number generation algorithm if the current mark value is a read mark value, so as to update the current feature value based on the new feature value to obtain the target feature value; if the current mark value is an unread mark value, the current feature value is determined as the target feature value.

[0089] On the basis of the above device, optionally, the current mark value is an unread mark value or a read mark value, and the write position determination module 320 includes a to-be-written position determination unit;

[0090] The unit for determining the position to be written comprises: a subunit for determining a storage block to be processed and a subunit for determining a starting position to be written;

[0091] The storage block to be processed determining subunit is used to determine the first available storage block in the target storage space as the storage block to be processed if the current mark value is a read mark value; if the current mark value is an unread mark value, determine the termination storage block corresponding to the current mark value, so as to determine the next adjacent storage block of the termination storage block as the storage block to be processed;

[0092] The subunit for determining the starting position to be written is used to determine the starting position to be written corresponding to the target data based on the bad block inspection result of the storage block to be processed.

[0093] On the basis of the above-mentioned device, optionally, the subunit for determining the starting position to be written is specifically used to retrieve a predetermined bad block record table; wherein the bad block record table includes the physical address corresponding to the bad storage block in the target storage space; based on the physical address of the storage block to be processed and the bad block record table, the bad block inspection result of the storage block to be processed is determined; if the bad block inspection result is a good block, the storage block to be processed is determined as the starting position to be written; if the bad block inspection result is a bad block, the next storage block of the storage block to be processed is determined as the storage block to be processed, and the step of determining the bad block inspection result of the storage block to be processed is repeated to determine the starting position to be written corresponding to the target data based on the bad block inspection result.

[0094] On the basis of the above device, optionally, the target data writing module 330 includes a target feature value unit;

[0095] A data splitting unit, used for dividing the target data into at least one sub-data to be written based on the preset unit capacity corresponding to each storage block in the target storage space;

[0096] The storage block unit to be written is used for the target characteristic value unit to determine at least one storage block to be written that is consistent with the number of at least one sub-data to be written, with the starting position to be written as the starting point; wherein the bad block inspection results of the storage block to be written are all good blocks;

[0097] The target data writing unit is used for the target characteristic value unit to write the target characteristic value and the corresponding sub-data to be written to each storage block to be written. If the storage block to be written is in a used state, the data in the storage block to be written is erased, and then the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written; if the storage block to be written is not in a used state, the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written.

[0098] Based on the above device, optionally, the device further includes: a repeated execution module;

[0099] A repeated execution module is used to update the target characteristic value to the current characteristic value on the preset characteristic value mark position; when a data write request to write the target data into the target storage space is received again, the steps of obtaining the current characteristic value and the current mark value, determining the starting position to be written, the target characteristic value, and writing the target data into the target storage space based on the target characteristic value and the starting position to be written are repeated.

[0100] The technical solution of the embodiment of the present invention, when receiving a data write request to write target data to the target storage space, obtains the current characteristic value on the characteristic value mark bit and the current mark value on the preset read mark bit, wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state, and then, based on the current mark value and the current characteristic value, determines the starting position to be written and the target characteristic value corresponding to the target data, thereby writing the target data to the target storage space based on the target characteristic value and the starting position to be written. The technical solution of the present invention determines the starting position of the data to be written through the current mark value and the current characteristic value. Since the starting position to be written has been determined before the data is written, it can be quickly and efficiently determined from which storage block of the target storage space to start writing according to the starting position to be written, avoiding the operation of clearing all data contents in the storage card before repeatedly writing data, reducing the time consumption of data writing; and there is no need to write data from the first storage block, so that the storage space of the storage card can be efficiently utilized.

[0101] The data writing device provided in the embodiment of the present invention can execute the data writing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0102] It is worth noting that the various units and modules included in the above system are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.

[0103] Embodiment 4

[0104] Figure 7 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 7 A block diagram of an exemplary electronic device 40 suitable for implementing exemplary embodiments of the present invention is shown. Figure 7 The electronic device 40 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0105] like Figure 7 As shown, the electronic device 40 is in the form of a general computing device. The components of the electronic device 40 may include but are not limited to: one or more processors or processing units 401, a system memory 402, and a bus 403 connecting different system components (including the system memory 402 and the processing unit 401).

[0106] Bus 403 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnect (PCI) bus.

[0107] The electronic device 40 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 40, including volatile and non-volatile media, removable and non-removable media.

[0108] System memory 402 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 404 and / or cache memory 405. Electronic device 40 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 406 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 403 via one or more data medium interfaces. Memory 402 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of various embodiments of the present invention.

[0109] A program / utility 408 having a set (at least one) of program modules 407 may be stored, for example, in memory 402, such program modules 407 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 407 generally perform the functions and / or methods of the embodiments described herein.

[0110] The electronic device 40 may also communicate with one or more external devices 409 (e.g., keyboards, pointing devices, displays 810, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 40, and / or may communicate with any device that enables the electronic device 40 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface 411. Furthermore, the electronic device 40 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 412. As shown, the network adapter 412 communicates with other modules of the electronic device 40 via the bus 403. It should be understood that although Figure 7 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 40, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0111] The processing unit 401 executes various functional applications and page processing by running the programs stored in the system memory 402, for example, implementing the data writing method provided by the embodiment of the present invention.

[0112] Embodiment 5

[0113] An embodiment of the present invention further provides a storage medium containing computer executable instructions, and when the computer executable instructions are executed by a computer processor, they are used to execute a data writing method, the method comprising:

[0114] When receiving a data write request to write target data to a target storage space, obtaining a current feature value on a preset feature value flag bit and a current mark value on a preset read mark bit; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state;

[0115] Based on the current mark value and the current feature value, determining a starting position to be written and a target feature value corresponding to the target data;

[0116] Based on the target characteristic value and the starting position to be written, the target data is written into the target storage space.

[0117] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0118] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0119] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0120] Computer program code for performing the operation of embodiments of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0121] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A data writing method, It is characterized in that include: When receiving a data write request to write target data to a target storage space, obtaining a current feature value on a preset feature value flag bit and a current mark value on a preset read mark bit; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state; Based on the current mark value and the current feature value, determining a starting position to be written and a target feature value corresponding to the target data; Based on the target characteristic value and the starting position to be written, the target data is written into the target storage space.

2. The method according to claim 1, It is characterized in that After writing the target data into the target storage space, the method further includes: Setting the mark value on the preset read mark position to an unread mark value; When receiving a data read instruction corresponding to the target storage space, switching the mark value on the preset read mark bit from the unread mark value to the read mark value; The unread mark value is used to indicate that the target storage space is in an unread state, and the read mark value is used to indicate that the target storage space is in a read state.

3. The method according to claim 1, It is characterized in that The current tag value is an unread tag value or a read tag value, and determining a target feature value based on the current tag value and the current feature value includes: If the current tag value is a read tag value, a new feature value is generated based on a preset random number generation algorithm, so as to update the current feature value based on the new feature value to obtain a target feature value; If the current mark value is an unread mark value, the current feature value is determined as a target feature value.

4. The method according to claim 1, It is characterized in that The step of determining the starting position to be written corresponding to the target data based on the current mark value and the current feature value includes: If the current mark value is a read mark value, determining the first available storage block in the target storage space as the storage block to be processed; If the current mark value is an unread mark value, determining a termination storage block corresponding to the current mark value, so as to determine a next adjacent storage block of the termination storage block as a storage block to be processed; Based on the bad block inspection result of the storage block to be processed, a starting position to be written corresponding to the target data is determined.

5. The method according to claim 4, It is characterized in that The step of determining the starting position to be written corresponding to the target data based on the bad block inspection result of the storage block to be processed comprises: Retrieving a predetermined bad block record table; wherein the bad block record table includes physical addresses corresponding to bad storage blocks in the target storage space; Determine a bad block inspection result of the storage block to be processed based on the physical address of the storage block to be processed and the bad block record table; If the bad block inspection result is a good block, the storage block to be processed is determined as the starting position to be written; If the bad block check result is a bad block, the next storage block of the storage block to be processed is determined as the storage block to be processed, and the step of determining the bad block check result of the storage block to be processed is repeated to determine the starting position to be written corresponding to the target data based on the bad block check result.

6. The method according to claim 1, It is characterized in that The step of writing the target data into the target storage space based on the target characteristic value and the starting position to be written includes: Based on the preset unit capacity corresponding to each storage block in the target storage space, dividing the target data into at least one sub-data to be written; Taking the starting position to be written as the starting point, determining at least one storage block to be written that is consistent with the number of the at least one sub-data to be written; wherein the bad block inspection results of the storage blocks to be written are all good blocks; For each storage block to be written, if the storage block to be written is in a used state, the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written after erasing the data in the storage block to be written; if the storage block to be written is in an unused state, the target characteristic value and the corresponding sub-data to be written are written to the storage block to be written.

7. The method according to claim 1, It is characterized in that After writing the target data into the target storage space, the method further includes: Updating the target feature value to the current feature value on the preset feature value mark; When a data write request to write the target data into the target storage space is received again, the steps of obtaining the current feature value and the current mark value, determining the starting position to be written, the target feature value, and writing the target data into the target storage space based on the target feature value and the starting position to be written are repeated.

8. A data writing device, It is characterized in that include: A data writing request module, configured to obtain a current characteristic value on a preset characteristic value flag bit and a current mark value on a preset read mark bit when receiving a data writing request to write target data to a target storage space; wherein the mark value on the preset read mark bit is used to indicate whether the target storage space is in a read state; A write position determination module, used to determine a to-be-written start position and a target characteristic value corresponding to the target data based on the current mark value and the current characteristic value; A target data writing module is used to write the target data into the target storage space based on the target characteristic value and the starting position to be written.

9. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data writing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data writing method according to any one of claims 1 to 7 when executed.