Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Embodiment 1
Present embodiment discloses a kind of method that writes data, and as shown in Figure 1, this method comprises the steps:
101, receive the instruction that in storage block, writes new data that send on upper strata (as computer operating system).
102, in all DSB data store block of storer, find out the DSB data store block at the data place of need revising.
103, in all empty storage blocks of storer at random select an empty storage block, and should the sky storage block as the empty storage block of selecting.
104, will need in the data revise part and make amendment, and amended new data combined with data become more new data, and with this more new data write in the above-mentioned empty storage block of selecting.
105, with the data erase in the DSB data store block that navigates in 101 steps, make this DSB data store block become an empty storage block.
The method that writes data that present embodiment provides is written in technical scheme in the empty storage block of selecting at random by adopting the data that will write, and has obtained the beneficial effect that can realize uniformly each storage block being carried out write operation.Further, again because the uniform numerical value of the number of times of the write operation that each storage block is performed, so overcome some other storage block because the number of times of the write operation that is performed is too much, the extent of damage that causes is more serious, even the technical matters that can't reuse, also improved the operable number of times of storage block simultaneously.
Embodiment 2
Present embodiment discloses a kind of device that writes data, and as shown in Figure 2, this device comprises: receiver module 21, and locating module 22 is selected module 23, and writing module 24 is wiped module 25.
Receiver module 21 is used to receive the instruction that writes new data; Locating module 22 is used to locate the DSB data store block at the data place that needs revise; Selecting module 23 is used for selecting an empty storage block at random from all empty storage blocks; Writing module 24 is used for that described data are combined the back with new data and is new data more, and described more new data is write in the described empty storage block of selecting at random; Wipe the DSB data store block that module 25 is used for navigating to and be erased to the sky storage block.
The device that writes data that present embodiment provides is convenient to write the realization of the method for data, also for example can improve simultaneously: flash memory etc., storage block is the serviceable life of impaired storer easily.
Embodiment 3
Scene when the present embodiment combination is made amendment to the data in the storage block specifically describes the method that writes data, and as shown in Figure 3, this method comprises the steps:
In order to set forth conveniently, suppose that the physical address in flash memory storage district is that establishing each storage block is 0x100 byte from 0x0000000 to 0x00007800 in the present embodiment, then total 0x78 storage block.Correspondingly, the physical block number of each storage block is that 0x00 is to 0x77.Be used for this storage block logical block number (LBN) of mark in the first byte of each storage block, file can regard that the set of a plurality of storage blocks and the storage block in the file are that logical block number (LBN) according to each storage block is tied as.
According to the difference of storage block logical block number (LBN), storage block is divided for two types in the present embodiment:
Empty storage block refers to that logical block number (LBN) is the storage block of 0xFF.Null data area refers to the zone that first byte in the sky storage block (being logical block number (LBN)) byte is in addition formed, if then all bytes of null data area all are 0xFF, this sky storage block can write data at any time; Otherwise this sky storage block is the empty storage block of the data of can not writing direct, and needs this sky storage block is carried out erase operation, even should all bytes of sky storage block become 0xFF, then empty storage block just becomes the empty storage block that can write data at any time.Especially, the empty storage block of the data of can not writing direct is called " the empty storage block that record is arranged ".
DSB data store block refers to the storage block of logical block number (LBN) in 0x01 arrives the 0x78 scope.The data that data field data index is stored according to first byte in the storage block (being logical block number (LBN)) byte in addition.The data field data are considered to effective file data.
301, after storer energising, the sum of statistical memory hollow storage block, and generate one and be not more than this total random number.
Be specially in the present embodiment: open up a variable N=0 at internal memory, pointer P is set points to flash memory storage district physics first address, be P=0x00000000, pointer P is from 0x00000000, finish to 0x00007800, the step-length of P is 0x100, i.e. P=P+0x100, and then P always points to the storage block logical block number (LBN).Judge whether P storage block logical block number (LBN) pointed is 0xFF.If 0xFF makes N=N+1, when P=0x00007800, the value of N is exactly the sum of sky storage block.Total N according to the empty storage block that obtains generates a random number M.The scope of the M of random number is 1<=M<=N.M produces by a relevant function f (M), also can be simple select integer between 1<=M<=N.These two kinds of methods may be used to generate the random number in the present embodiment.
302, judge whether the sum of empty storage block is identical with the random number that generates, identical with the random number of generation if sky is stored fast sum, then execution in step 303; If the sum of empty storage block is different with the random number of generation, then execution in step 309.
Be specially in the present embodiment: judge whether M equals N, execution in step 303 if M equals N; The execution in step 309 if M is not equal to N.
When the number of storer hollow storage block seldom the time, according to the random number that empty storage block sum generates, the possibility that equates with empty storage block sum will become big.In the present embodiment, utilize this possibility, judge the scheme whether sum of empty storage block equates with random number, obtain the technique effect that to recognize the present total situation of sky storage block by employing.And in this process of present embodiment, the random number that computing machine generates just is equivalent to the default value that the user is provided with, this default value is equivalent to a thresholding, can recognize whether current empty storage block sum is in situation seldom, so that take appropriate measures.
303, the sum of DSB data store block also generates a random number that is not more than this DSB data store block sum at random in the statistical memory; According to the sum of the empty storage block that counts in 301 steps, generate a random number that is not more than this sky storage block sum at random simultaneously.
Be specially in the present embodiment: apply for two memory variable A and B.Be recorded in the sum of the DSB data store block that finds in the storer with A, be recorded in the sum (make in the present embodiment B=N both can) of the empty storage block that finds in the storer with B, and generate a random number a according to the value of A, the scope of a is 1<=a<=A; Value according to B generates a random number b, and the scope of b is 1<=b<=B.
304, in DSB data store block, select a data storage block according to the random number that the DSB data store block sum generates; The random number that generates according to empty storage block sum is selected a target empty storage block in empty storage block simultaneously.
Be specially in the present embodiment: open up a local variable N4=0 at internal memory, pointer T is set points to flash memory storage district physics first address, be T=0x00000000, pointer T is from 0x00000000, finish to 0x00007800, the step-length of pointer T is 0x100, i.e. T=T+0x100, and then pointer T always points to the storage block logical block number (LBN).Judge that the current storage block logical block number (LBN) pointed of pointer T is whether in 0x01 to 0x78 scope.If, N4=N4+1 then.In the time of N4=a, the current DSB data store block pointed of pointer T is the DSB data store block n4 selected according to random number a, and selected this DSB data store block n4.
Simultaneously, open up a local variable N3=0 at internal memory, pointer S is set points to flash memory storage district physics first address, be S=0x00000000, pointer S finishes to 0x00007800 from 0x00000000, and the step-length of pointer S is 0x100, be S=S+0x100, then pointer S always points to the storage block logical block number (LBN).Judge whether the current storage block logical block number (LBN) pointed of pointer S is 0xFF.If 0xFF, then N3=N3+1.In the time of N3=b, the pairing empty storage block of pointer S is the empty storage block n3 selected according to random number b, and selected this sky storage block n3, is target empty storage block n3.
Process about the empty storage block n3 that selects at random in present embodiment 303,304 steps also can adopt following method to realize:
This method is mainly tabulated and is realized the purpose of an empty storage block of stochastic searching by setting up empty storage block.
3031, all storage blocks in the traversal storer, finding is free storage block in the present storer.
3041, set up one include find be free storage block address list or the physical block number tabulation of free storage block is arranged, from described tabulation, select an empty storage block at random.
In the present embodiment, concrete grammar can be: the first address that pointer P points to the storage block of physical address minimum in the flash memories is set.P=P+i* (0x100) just represents to point to the first address (because the length of each storage block is the 0x100 byte, so pointer P always points to each storage block first address) of i+1 storage block so.The value of i is from 0 to 0x77, and 0x78 storage block altogether then can find the first address of a storage block by the value of i.
In internal memory, open up an array freeblock[78] be used for writing down the value of the i of empty storage block.Allow the value of i traverse 0x77 from 0, judge whether the pairing storage block of i value is the sky storage block, if empty storage block, then with the value record of i in freeblock.Such as current time, the number of empty storage block is 5, and corresponding i value is respectively 0x2,0x12,0x33,0x40,0x59, freeblock[0 so]=0x2, freeblock[1]=0x12, freeblock[2]=0x33, freeblock[3]=0x 40, freeblock[4]=0x 59, the random number between producing 1~5.Such as this random number is 2, so just can by look for the 2nd value of freeblock array or 5-2 value (promptly look for freeblock[2-1] or look for freeblock[5-2], the 5th, the number of sky storage block), thus obtain the i value of an empty storage block.Also can be according to the i value, i*0x100 is exactly the first address of this sky storage block.So can in array freeblock, directly write down the first address of empty storage block, therefrom select an empty storage block then at random.
305, judge whether the described empty storage block of selecting at random is the empty storage block that record is arranged, if the result who judges is for being that then execution in step 306; Otherwise, direct execution in step 307.
Be specially in the present embodiment: judge whether empty storage block n3 is the empty storage block that record is arranged.
306, wiping this has the data of storing in the empty storage block of record, and making this empty storage block that record is arranged is empty storage block.
307, the data in the DSB data store block of selecting are written in the empty storage block of selecting, wipe the data in the DSB data store block of selecting then.
Be specially in the present embodiment: all be read into the data of storing among the DSB data store block n4 in the internal memory, then logical block number (LBN) (being first byte) data in addition are written among the empty storage block n3 that selects at random by 305 steps, after these data have all been write, logical block number (LBN) with DSB data store block n4 writes among the sky storage block n3 again, simultaneously the data of storing among the obliterated data storage block n4.Be about to empty storage block n3 and become DSB data store block n3, DSB data store block n4 is become sky storage block n4.
The scheme that present embodiment provides is because considered that some DSB data store block may be in case be written into permanently effective data, just seldom be performed the situation of write operation, so after the storer energising, adopted the technical scheme that the data in the DSB data store block of selecting at random can be transferred in the empty storage block of selecting at random, even if DSB data store block is written into permanently effective data so, still this DSB data store block can be become the sky storage block, it is participated in to be performed in the scene that writes data manipulation, obtained the number of times that can make storage block be performed write operation and obtained balanced beneficial effect.
308, counter being set and making the initial count value of this counter is zero, waits for that simultaneously upper strata (as: computer operating system) sends the instruction that writes new data.
Be specially in the present embodiment: variable J of application in internal memory, be used for the number of times of record modification storer, and the initial value that J is set is 0, wait for that then the needs that send on the upper strata revise the instruction of data.
When the storage block in the storer was carried out the write-once operation, counter then added up to add one on initial value, so that the number of times of the write operation that record storage was performed.
309, receive the instruction that writes new data of sending on the upper strata and find the DSB data store block at the data place of need revising.
Be specially in the present embodiment: if need the DSB data store block x logical block number (LBN) at the data place of modification is x, pointer P is set points to flash memory storage district physics first address, be P=0x00000000, pointer P is from 0x00000000, finish to 0x00007800, the step-length of P is 0x100, i.e. P=P+0x100, and then P always points to the storage block logical block number (LBN).Judge whether the current storage block logical block number (LBN) pointed of P is X.If then this DSB data store block is the DSB data store block x that needs the data place of modification.If not, then P=P+0x100 continues to search.
In the present embodiment, also can find the DSB data store block at the data place that needs modification by physical block number, if this need revise to such an extent that the physical block number of data storage block is Y, then make a pointer P from 0x00000000, finish to 0x00007800, the step-length of P is 0x100, though P=Y*0x100, the pairing storage block of P be need revise the data storage block.
310, the sum of statistical memory hollow storage block, and generate a random number that is not more than in this sky storage block sum scope.
Be specially in the present embodiment: open up a variable N 2=0 at internal memory, pointer P is set points to flash memory storage district physics first address, be P=0x00000000, pointer P is from 0x00000000, finish to 0x00007800, the step-length of P is 0x100, i.e. P=P+0x100, and then P always points to the storage block logical block number (LBN).Judge whether P storage block logical block number (LBN) pointed is 0xFF, if 0xFF then makes N2=N2+1.When P=0x00007800, the value of N2 is exactly the sum of sky storage block.Total N2 according to the empty storage block that obtains generates a random number w.The scope of random number w is 1<=w<=N2.W produces by a relevant function f (w), also can be simple select integer between 1<=w<=N2.These two kinds of methods may be used to generate the random number in the present embodiment.
311, in storer, search the sky storage block, each the empty storage block that finds is counted, when the value of counting when equating, select the current empty storage block that finds with random number, and the empty storage block of should the conduct of sky storage block selecting at random.
Be specially in the present embodiment: open up a local variable N5=0 at internal memory, pointer Y is set points to flash memory storage district physics first address, be Y=0x00000000, pointer Y is from 0x00000000, finish to 0x00007800, the step-length of pointer Y is 0x100, i.e. Y=Y+0x100, and then pointer S always points to the storage block logical block number (LBN).Judge whether the current storage block logical block number (LBN) pointed of pointer Y is 0xFF.If 0xFF, then N5=N5+1.In the time of N5=w, the pairing empty storage block of pointer Y is the empty storage block n5 selected according to random number w, and selected this sky storage block n5.
Also can adopt by setting up empty storage block about the process of the empty storage block n5 that selects at random in present embodiment 310,311 steps and tabulate and realize the method for an empty storage block of stochastic searching.Concrete method of operating is identical with the method for step 3031 and 3041, is not here giving unnecessary details.
312, judge whether the empty storage block of selecting at random is the empty storage block that record is arranged, if then execution in step 313; If not, then direct execution in step 314.
313, wiping this has the data of storing in the empty storage block of record, makes this have the empty storage block of record to become the sky storage block.
314, the data of storing in the DSB data store block that finds in 309 steps are read in the internal memory, keep logical block number (LBN) constant, in internal memory that the data modification that needs in the data field to revise is intact simultaneously, to revise the data more new data (not containing logical block number (LBN)) that generates that combines with the data field data then earlier and write in the empty storage block of selecting at random by 312 steps, logical block number (LBN) be written in this sky storage block again.
In the present embodiment, adopted first more new data to write described empty storage block, after logical block number (LBN) is write the technical scheme of described empty storage block, obtained and avoided in ablation process, because it is incomplete that the generation power down causes writing data, make this sky storage block be in the beneficial effect of " the empty storage block that record is arranged " state, also make the DSB data store block that becomes that this empty storage block that record is arranged can be wrong simultaneously.
315, wipe the data of storing in the DSB data store block that finds in 309 steps, make this DSB data store block become the sky storage block.
314 and 315 steps are specially in the present embodiment: the data of DSB data store block x are read in the internal memory, when keeping logical block number (LBN) constant, in internal memory that the data modification that needs in the data field to revise is intact, to revise earlier the back data combine with the data field data generation more new data all be written among the empty storage block n5 that finds by step 311, DSB data store block x logical block number (LBN) is written among this sky storage block n5 (promptly empty storage block n5 being become DSB data store block n5) again, the data of storing among the obliterated data storage block x make DSB data store block x become sky storage block (even all bytes of this DSB data store block become 0xFF) simultaneously.
316, add one on the count value to set counter.
Be specially in the present embodiment: make J=J+1.
317, judge whether the count value of counter reaches pre-determined number, if the result who judges is for reaching pre-determined number, then execution in step 318; If the result who judges is not for reaching pre-determined number, this EO then.
Be specially in the present embodiment: it is 30 that preset times is set, and judges whether the J value equals 30, if the J value equals 30, then execution in step 318; Otherwise, execution in step 324.
318, the sum of DSB data store block also generates a random number that is not more than this DSB data store block sum at random in the statistical memory; The sum of statistical memory hollow storage block also generates a random number that is not more than this sky storage block sum at random simultaneously.
Concrete grammar is identical with embodiment in 303 steps in the present embodiment.
319, in DSB data store block, select a data storage block according to the random number that the DSB data store block sum generates; The random number that generates according to empty storage block sum is selected a target empty storage block in empty storage block simultaneously.
Concrete grammar is identical with embodiment in 304 steps in the present embodiment.
320, judge whether this empty storage block of selecting at random is the empty storage block that record is arranged, if then execution in step 321; If not, then direct execution in step 322.
Concrete grammar is identical with embodiment in 305 steps in the present embodiment.
321, wiping this has the data of storing in the empty storage block of record, and making this empty storage block that record is arranged is empty storage block.
Concrete grammar is identical with embodiment in 306 steps in the present embodiment.
322, the data in the DSB data store block of selecting are written in the empty storage block of selecting, wipe the data in the DSB data store block of selecting then, make this DSB data store block become the sky storage block.
Concrete grammar is identical with embodiment in 307 steps in the present embodiment.
When the value of counter arrives pre-determined number, the number of times that the write operation that storer is performed is described has reached default number of times, and be subjected to damage to a certain extent with regard to having represented the sky storage piece that exists in the present storer because of the write operation that has been performed pre-determined number this moment.In order to reduce the empty storage block extent of damage of present existence, present embodiment adopts the data in the DSB data store block that will select at random to transfer to technical scheme in the empty storage block of selecting at random, also obtained the beneficial effect that can balanced each storage block be performed the write operation number of times when having reduced the present empty storage block extent of damage.
323, with the count value zero clearing of counter.
Be specially in the present embodiment: make J=0.
324, process ends.
The scheme that present embodiment provides, by adopting the data to need to revise to write the technical scheme of the empty storage block of selecting at random, overcome in the prior art, select the sky storage block in order and the easy appearance that causes comes the situation that the more preceding empty storage block of order is carried out write operation continually to sequence number because be, obtained the technique effect that can make to the execution write operation of each storage block equilibrium in the storer, improve the spendable number of times of storage block, also be equivalent to prolong the spendable life-span of storer.And in writing the process of data, write logical block number (LBN) after the first write data, thereby has good anti-lost electric work energy.
Embodiment 4
Present embodiment has specifically described a kind of device that writes data, and as shown in Figure 4, this device comprises: second judge module 401, second Switching Module 402 at random, receiver module 403, locating module 404, select module 405, first judge module 408, the first is removed module 409, writing module 406, wipe module 407, accumulative total module 410, the three judge modules 411, the three are Switching Module 412 at random.
Second judge module 401 is used for judging that whether current empty storage block sum is less than default value after the storer energising; Second when Switching Module 402 is used for current empty storage block sum less than default value at random, the data in the DSB data store block of selecting is at random write in the target empty storage block of selecting at random, and the described DSB data store block of selecting at random is erased to the sky storage block; Receiver module 403 is used to receive the instruction that writes new data; Locating module 404 is used to locate the DSB data store block at the data place that needs revise; Selecting module 405 is used for selecting an empty storage block at random from all empty storage blocks; First judge module 408 is used to judge whether the described DSB data store block of selecting at random is the empty storage block that record is arranged; First removes module 409 is used for when the judge module judgement is, the empty memory block erasing of record is arranged is empty storage block with described; Writing module 406 is used for described data and new data are combined into more new data, and described more new data is write in the described empty storage block of selecting at random; Wipe module 407 and be used to wipe data in the DSB data store block that navigates to; The number of times that accumulative total module 410 is used for the write operation that will at every turn storage block be carried out is accumulated to the total degree of write operation; The 3rd judge module 411 is used to judge that whether the total degree of said write operation is greater than preset times; The 3rd when Switching Module 412 is used for total degree when write operation greater than preset times at random, data in the DSB data store block of selecting are at random write in the target empty storage block of selecting at random, and the described DSB data store block of selecting at random is erased to the sky storage block, the total degree with write operation makes zero simultaneously.
In the present embodiment, second at random Switching Module 402 comprise: first selects unit 4021, the second selects unit 4022, the second judging units, 4025, the second clearing cells, 4026, the second writing units, 4023, the second erase units 4024.
First selects unit 4021 is used for selecting a data storage block at random from all DSB data store block; Second selects unit 4022 is used for selecting a target empty storage block at random from all empty storage blocks; Second judging unit 4025 is used to judge whether described target empty storage block is the empty storage block that record is arranged; Second clearing cell 4026 is used for when second judgment unit judges is, the empty memory block erasing that record will be arranged is empty storage block; Second writing unit 4023 is used for the data in the described DSB data store block are write described target empty storage block; The DSB data store block that second erase unit 4024 is used for selecting at random is erased to the sky storage block.
Wherein, first select unit 4021 and comprise: the first statistics subelement 40210, the first generates subelements 40211, the first locator unit 40212.
The first statistics subelement 40210 is used for the number of statistics storage block; First generates subelement 40211 is used to generate a random number that is not more than all DSB data store block sums; The first locator unit 40212 is used to utilize the data storage block in described random number location.
Especially, first select unit 4021 and can search subelement by second and replace in the device of present embodiment; Correspondingly, second select unit 4022 and can set up subelement by second; Correspondingly, second writing unit 4023 can be selected subelement by second and replaces.
Second searches subelement is used to travel through all storage blocks and searches institute free storage block arranged; Second set up subelement be used to set up one include find be free storage block address list or the physical block number tabulation of free storage block arranged; Second selects subelement is used for selecting a target empty storage block at random from described tabulation.
In the present embodiment, this second is selected unit 4022 and comprise: the second statistics subelement 40221, the second generates subelements 40222, the second locator unit 40223.
The second statistics subelement 40221 is used to add up the number of empty storage block; Second generate subelement 40222 be used to generate one be not more than the random number of free storage block sum arranged; The second locator unit 40223 is used to utilize the target empty storage block in described random number location.
In the present embodiment, select module 405 and comprise: statistic unit 4051, generation unit 4052, positioning unit 4053.
Statistic unit 4051 is used to add up the number of empty storage block; Generation unit 4052 be used to generate one be not more than the random number of free storage block sum arranged; Positioning unit 4053 is used to utilize the empty storage block in described random number location.
Especially, the statistic unit of selecting module 405 4051 in the present embodiment device, generation unit 4052, positioning unit 4053 can also be with searching the unit, set up the unit and select the unit to replace.Wherein, searching the unit is used to travel through all storage blocks and finds institute free storage block arranged; Set up the unit be used to set up one include find be free storage block address list or the physical block number tabulation of free storage block arranged; Selecting the unit is used for selecting an empty storage block at random from described tabulation.
The DSB data store block of 404 location of the locating module in the present embodiment device is made up of logical block number (LBN) and data field data in addition, and the then described data that need to revise are the data field data.So corresponding, writing module 406 combines the data field data earlier and writes in the described empty storage block of selecting at random with new data, described logical block number (LBN) is write in the described empty storage block of selecting at random again.
Writing module 406 in the present embodiment comprises: reading unit 4061, combining unit 4062, writing unit 4063.
Reading unit 4061 is used for described data are read into internal memory; Combining unit 4062 be used for internal memory with described data field data with generate more new data after new data combines; Writing unit 4063 is used for described more new data and logical block number (LBN) are write the described empty storage block of selecting at random.
In the present embodiment the 3rd Switching Module 412 at random comprises: the 3rd selects unit 4120, the four selects unit 4121, the three judging units, 4125, the three clearing cells, 4126, the three writing units, 4122, the three erase units, 4123, the Sangui terrace zero locations 4124.
The 3rd selects unit 4120 is used for selecting a data storage block at random from all DSB data store block; The 4th selects unit 4121 is used for selecting a target empty storage block at random from all empty storage blocks; The 3rd judging unit 4125 is used to judge whether described target empty storage block is the empty storage block that record is arranged; The 3rd clearing cell 4126 is used for when second judgment unit judges is, the empty memory block erasing that record will be arranged is empty storage block; The 3rd writing unit 4122 is used for the data in the described DSB data store block are write described target empty storage block; The 3rd erase unit 4123 is used for the described DSB data store block of selecting at random is erased to the sky storage block; Sangui terrace zero location 4124 is used for the total degree of write operation is made zero.
In the present embodiment device the 3rd selected unit 4120 and comprised: the 3rd statistics subelement 41200 is used for the number of statistics storage block; The 3rd generates subelement 41201 is used to generate a random number that is not more than all DSB data store block sums; The 3rd locator unit 41202 is used to utilize the data storage block in described random number location.
In the present embodiment device the 4th selected unit 4121 and comprised: the 4th statistics subelement 41210, the four generates subelement 41211, the four locator unit 41212.
The 4th adds up subelement 41210, is used to add up the number of empty storage block; The 4th generates subelement 41211, be used to generate one be not more than the random number of free storage block sum arranged; The 4th locator unit 41212 is used to utilize the target empty storage block in described random number location.
Especially, the 4th in the present embodiment device selected unit 4121 and can also be searched subelement, the 4th by the 4th and set up subelement, the 4th and select subelement and form, and wherein the 4th searches subelement, is used to travel through all storage blocks and searches institute free storage block is arranged; The 4th sets up subelement, be used to set up one include find be free storage block address list or the physical block number tabulation of free storage block arranged; The 4th selects subelement, is used for selecting a target empty storage block at random from described tabulation.
The embodiment of the invention mainly is used in the various storeies, for example: flash memory etc. also can prolong the serviceable life of storer simultaneously so that realize improving the operable number of times of storage block.
Through the above description of the embodiments, the those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential common hardware, can certainly pass through hardware, but the former is better embodiment under a lot of situation.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in the storage medium that can read, floppy disk as computing machine, hard disk or CD etc. comprise that some instructions are used so that a method that contains each embodiment of terminal execution the present invention of storer.
The above; only be the specific embodiment of the present invention, but protection scope of the present invention is not limited thereto, anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.