Abstract:
A management method for reducing the utilization rate of random access memory (RAM) while reading data from or writing data to the flash memory is disclosed. A physical memory set is constructed from a plurality of physical memory blocks in the flash memory. A logical set is constructed from a plurality of logical blocks wherein the data stored in the logical set are stored in the physical memory set. Further, the data stored in each of the logical blocks are stored in one number of physical memory blocks. A mapping table is constructed and includes a hash function, a logical set table, a physical memory set table, and a set status table for managing the relationship among the physical memory sets, physical memory blocks, and logical blocks while reading data from or writing data to the flash memory. Further, the management method operates and maintains the physical memory sets, the physical memory blocks, and the logical blocks at a set level so that the utilization rate of random access memory is reduced to decrease the access capacity of the random access memory while operating the physical memory blocks and the logical blocks of the flash memory.

Description:
FIELD OF THE INVENTION 
       [0001]    The present invention relates to a method for managing the utilization rate of memory, and more particularly to a management method for reducing the utilization rate of random access memory (RAM) to decrease the access capacity of the random access memory while reading data from or writing data to the flash memory. 
       BACKGROUND OF THE INVENTION 
       [0002]    Regarding the technical field of the conventional flash memory, the architecture of flash memory includes a flash memory chip having a plurality of physical flash memory planes. Further, one of physical flash memory planes is composed of hundreds of flash memory blocks wherein the memory capacity of a flash memory block is in a range from 16 KB to 128 KB. 
         [0003]    Please refer to  FIG. 1 .  FIG. 1  is a management architecture of the conventional flash memory. There are many kinds of management methods of the flash memory. However, while implementing the management methods, it is required to establish a mapping table (abbreviated as “MT”, or named as address translation table) having logical addresses (LAS) and physical addresses (PAS) in the flash memory. Furthermore, before using the flash memory, it is necessary to construct a mapping table and store the mapping table in the random access memory (RAM) to be inquired so that the flash memory can be operated in the manner of management architecture shown in  FIG. 1 . However, considering the manufacturing cost of the flash memory, the capacity of the random access memory (RAM) is limited. Thus, if the storage space for storing the mapping table is greater than the physical storage space of the random access memory (RAM), the management method of the flash memory needs to be changed. 
         [0004]    Please refer to  FIG. 2 .  FIG. 2  is a flow chart of management method of the conventional flash memory. The management method adopts the way of on-demand fetching. That is, when the host submits an inquiry request, the management method constructs a mapping table partially associated with the inquiry request, or fetches the mapping table partially associated with the inquiry request to be stored in the random access memory (RAM). The management method then starts to inquire the mapping table. Therefore, it is not necessary to save the whole mapping table to the random access memory (RAM). The detailed steps are described as follows: 
         [0005]    ( 1 A) Start. 
         [0006]    ( 2 A) The host issues an access command to access the flash memory and assigns a logical access address. 
         [0007]    ( 3 A) The method checks the partial mapping table stored in the random access memory (RAM). 
         [0008]    ( 4 A) The method identifies the partial mapping table to check whether the information corresponding to the logical access address is stored. If yes, go to step ( 5 A), and if no, proceed to step ( 4 A 1 ). 
         [0009]    ( 4 A 1 ) The method constructs the partial mapping table having the information corresponding to the logical access address or reads the partial mapping table from the flash memory. 
         [0010]    ( 4 A 2 ) The method saves the partial mapping table to the random access memory (RAM) to be inquired. If the capacity of the random access memory (RAM) is exhausted, the temporarily unused portion of the partial mapping table is erased. 
         [0011]    ( 5 A) The method inquires the mapping table to acquire the physical addresses corresponding to the logical access address. 
         [0012]    ( 6 A) The method access the flash memory based on the physical addresses. 
         [0013]    ( 7 A) End. 
         [0014]    However, for the purpose of decreasing the access response time by reducing the time of the on-demand fetching when constructing the partial mapping table, it is required to divide the mapping table into a plurality of regions and only a portion of regions correspond to a specific range of physical memory addresses. While the host reads the data on the specific range, the specific range of physical memory addresses is scanned in order to construct the partial mapping table including the specific range of physical memory addresses. 
         [0015]    As shown in  FIG. 3 , a plurality of logical blocks having a smaller address range corresponds to a flash memory plane having a greater address range. For example, a flash memory plane is composed of the amount of 512 physical memory blocks (PBA), which are assigned as the numbers “0” to “511”. A plurality of logical blocks (LAB) are assigned as the numbers “0” to “499” and total amount of logical blocks is 500. The logical blocks (LAB) corresponds to the physical memory blocks. The additional twelve physical memory blocks serves as the function of out-place update or as a buffer region if some bad blocks are located within the physical memory blocks (PBA). The term of out-place update means that the new data is written to different regions for reducing the updated time when updating a new memory block. The bad clocks are native defects in the flash memory after the flash memory are manufactured or used.  FIG. 3  shows the partial mapping table in the mapping table to be inquired by the logical blocks (LAB) including numbers “0” to “499”. 
         [0016]    If the host accesses a block, e.g. number “496”, in the logical block (LAB) and the mapping table shown in  FIG. 3  is not stored in the random access memory (RAM), it is required to scan numbers “0” to “511” of the physical memory blocks (PBA) in the flash memory for constructing the mapping table within the random access memory (RAM). Then, the host inquires the mapping table and identifies that the data of the number “496” in the logical block (LAB) is stored in the number “69” of the physical memory blocks (PBA). Finally, the data of the number “69” in the physical memory blocks (PBA) can be accessed. 
         [0017]    The feature of the above-mentioned method is only applicable to the random access memory (RAM) with the limited capacity. The disadvantage is that it takes a lot of time to make on-demand fetching or scan the flash memory for constructing different partial mapping tables when the addresses accessed by the host are variable from time to time. Moreover, such situation becomes more severe if the capacity of the flash memory is increased. 
         [0018]    Additionally, within the physical memory blocks (PBA) of the partial mapping table, if the amount of bad blocks in the physical memory blocks (PBA) is greater than the amount of the effective blocks in the partial mapping table, some logical blocks (LAB) cannot correspond to the addresses of the physical memory blocks (PBA), thereby resulting in data-storing errors of the flash memory. Further, the file system of the flash memory is damaged and all the data are thus lost. For example, if there are twelve or more bad blocks of the physical memory blocks (PBA) in the flash memory plane, the above situation occurs. 
       SUMMARY OF THE INVENTION 
       [0019]    One objective of the present invention is to provide a management method for reducing the utilization rate of random access memory (RAM) while reading data from or writing data to the flash memory so that the requirement of the random access memory is decreased to be applicable to the portable device having limited random access memory (RAM). 
         [0020]    Another objective of the present invention is to provide a management method for reducing the utilization rate of random access memory while reading data from or writing data to the flash memory. If the bad blocks in the flash memory exceeds a predetermined threshold amount, e.g. twelve bad blocks in a physical flash memory plane, the management method is capable of maintaining the data-accessing reliable and correct. 
         [0021]    According to the objectives, the present invention sets forth a management method for reducing the utilization rate of random access memory while reading data from or writing data to the flash memory. A physical memory set is constructed from a plurality of physical memory blocks in the flash memory. A logical set is constructed from a plurality of logical blocks wherein the data stored in the logical set are stored in the physical memory set. Further, the data stored in each of the logical blocks are stored in one number of physical memory blocks. A mapping table is constructed and includes a hash function, a logical set table, a physical memory set table, and a set status table for managing the relationship among the physical memory sets, physical memory blocks, and logical blocks while reading data from or writing data to the flash memory. Further, the management method operates and maintains the physical memory sets, the physical memory blocks, and the logical blocks at a set level so that the utilization rate of random access memory is reduced to decrease the access capacity of the random access memory while operating the physical memory blocks and the logical blocks of the flash memory. Therefore, the management method is capable of reducing the utilization rate of random access memory to increase the reliability and correctness of the data-accessing procedures. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0022]    The foregoing aspects and many of the attendant advantages of this invention will become more readily appreciated as the same becomes better understood by a reference to the following detailed description, when taken in conjunction with the accompanying drawings, wherein: 
           [0023]      FIG. 1  is a management architecture of the conventional flash memory; 
           [0024]      FIG. 2  is a flow chart of management method of the conventional flash memory; 
           [0025]      FIG. 3  is a mapping table of physical memory blocks and logical blocks in the conventional flash memory; 
           [0026]      FIG. 4  illustrates an architecture definition view of the flash memory according to one embodiment of the present invention; 
           [0027]      FIG. 5  illustrates a data architecture view of the hash function in the mapping table according to one embodiment of the present invention; 
           [0028]      FIG. 6  illustrates a data architecture view of the logical set table in the mapping table according to one embodiment of the present invention; 
           [0029]      FIG. 7  illustrates a data architecture view of the physical memory sets in the mapping table according to one embodiment of the present invention; 
           [0030]      FIG. 8A  illustrates a data architecture view of the set status table in the mapping table according to one embodiment of the present invention; 
           [0031]      FIG. 8B  illustrates a data architecture view of the status presentation sequence of the set status table according to one embodiment of the present invention; 
           [0032]      FIG. 9  is a flow chart of management method for reducing the utilization rate of the random access memory (RAM) in the flash memory according to one embodiment of the present invention; 
           [0033]      FIG. 10  is a flow chart of writing data and updating the mapping table according to one embodiment of the present invention; 
           [0034]      FIGS. 11A-11B  are detailed flow charts of writing the updated mapping table according to one embodiment of the present invention; and 
           [0035]      FIGS. 12A-12B  are detailed flow charts of reading the data indices according to one embodiment of the present invention. 
       
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
       [0036]    Please refer to  FIG. 4 .  FIG. 4  illustrates an architecture definition view of a management method used in flash memory for reducing the utilization rate of random access memory (RAM) according to one embodiment of the present invention. The physical memory set “S” or “S′” includes the amount “m” of physical memory blocks “PB 1 ” to “PBM” in the flash memory  100 , and the logical set “L” or “L′” includes the amount “n” of logical blocks “LAB 1 ” to “LABN”. The data in the same logical set are stored in the same physical memory set wherein the amount “n” is smaller than or equal to the amount “m”. The data stored in each of the logical blocks “LAB 1 ” to “LABN” are not necessarily stored in a specific number of physical memory blocks. 
         [0037]    That is, while writing or updating a logical block “LABA”, the logical block address (LBA) corresponds to the physical memory set “S” after inquiring a mapping table  10 . The mapping table  10  includes a hash function  11 , a logical set table  12 , a physical memory set table  13 , and a set status table  14 . 
         [0038]    If the logical block “LABA” has no written data, one physical memory block “PBC” is selected from the physical memory set “S” and the data are written to the physical memory block “PBC”. If the logical block “LABA” has written data and the written data are stored in the physical memory blocks “PBC” of the physical memory set “S”, and the physical memory set “S” includes another unused physical memory block “PBD”, new data are written into the physical memory block “PBD” and the content of the physical memory block “PBC” are set as invalidation status. In this case, if there is no physical memory blocks “PB 1 ” to “PBM” in the physical memory set “S”, the management method performs a step of garbage collection. In other words, the management method searches an unused physical memory set “S′” in the flash memory  100  and copies the effective data stored in the physical memory blocks “PB 1 ” to “PBM” of the physical memory set “S” to the unused physical memory set “S′”. Then, the physical memory set “S” is released and the management method starts to update the mapping table  10 . 
         [0039]      FIG. 5  illustrates a data architecture view of the hash function  11  in the mapping table  10  of a management method used in flash memory for reducing the utilization rate of random access memory according to one embodiment of the present invention. The hash function  11  serves as a divider for receiving the logical addresses “LA 1 ” to “LAN” from the logical blocks “LAB 1 ” to “LABN” to be the input values. After the divider performs the dividing operation, the hash function  11  outputs two values including a quotient, i.e. logical set number  111 , and a remainder, i.e. an inter-set number  112 . 
         [0040]      FIG. 6  illustrates a data architecture view of the logical set table  12  in the mapping table  10  of the management method used in the flash memory for reducing the utilization rate of random access memory according to one embodiment of the present invention. The logical set table  12  records each of the physical memory set numbers “SN” in the physical memory set “S” corresponding to each logical set number  111 . As shown in  FIG. 6 , the fifth logical set number  111  corresponds to the eighth physical memory set number “SN”. 
         [0041]      FIG. 7  illustrates a data architecture view of the physical memory set table  13  in the mapping table  10  of the management method used in the flash memory for reducing the utilization rate of random access memory according to one embodiment of the present invention. The physical memory set table  13  records each current set status index “SI” of each physical memory set numbers “SN”. As shown in  FIG. 6 , the current set status index “SI” of the eighth physical memory set numbers “SN” is “3”. 
         [0042]    Please refer to  FIGS. 8A and 8B .  FIG. 3A  illustrates a data architecture view of the set status table  14  in the mapping table  10  of the management method used in the flash memory for reducing the utilization rate of random access memory according to one embodiment of the present invention.  FIG. 8B  illustrates a data architecture view of the status presentation sequence of the set status table according to one embodiment of the present invention. The data-storing statuses associated with the physical memory sets “S” and “S′” are listed in the set status table  14  to be inquired by one set status index “SI”. In one embodiment, since the content listed in the set status table  14  is invariant, the set status table  14  can be written to the driver or firmware and recorded into the read-only memory (ROM), wherein the driver or firmware is capable of controlling the flash memory. In another case, the set status table  14  can be immovably written to the memory transformation layer of the flash memory. The set status table  14  is described as follows: 
         [0043]    (1) If the amount “n” of logical blocks “LAB 1 ” to “LABN”, i.e. one logical set, corresponds a physical memory set “S” or “S” including the amount “m” of physical memory blocks wherein the amount “n” is smaller than the amount “m”, the hash function  11  operates one of the logical addresses “LA 1 ” to “LAN” and generates an inter-set number  112  which is an integer between 0 and (n−1). 
         [0044]    (2) The data-storing statuses of the physical memory set “S” or “S′” are stored in the set status table  14 .  FIG. 8A  shows the amount “P” of data-storing statuses wherein each data-storing status is represented by one of the status presentation sequences “ 141 ” to “ 141 P”. 
         [0045]    (3) Referring to  FIG. 8B , a status presentation sequence “ 141 ” has the amount “m” of status presentation elements “1411” to “ 141 M” The length of each of the presentation elements “ 1411 ” to “ 141 M” is represented by the formula (unit: bits): Ceiling (log (n+2)), and thus the length of the status presentation sequence “ 141 ” is represented by the formula (unit: bits): m×Ceiling (log (n+2)). If the length is represented by decimal format, the value of each of status presentation elements “ 1411 ” to “ 141 M” is an integer between zero and (n+1). For an example of the set status table  14  in  FIG. 8A , four logical blocks are mapped to the physical memory set “S” having six physical memory blocks “PB 1 ” to “PB 6 ”. Further, the integer “6” represents the unused physical memory blocks and the integer “7” represents the physical memory blocks with invalidation or bad blocks. If the set status index “SI” of the physical memory set “S” is “3”, the status presentation sequence  144  is “666602” after inquiring the mapping table. That is, the first physical memory block “PB 1 ” of the physical memory set “S” includes the number “2” of logical block in the inter-set number  112 , the second physical memory block “PB 2 ” includes the number “0” of logical block in the inter-set number  112  and the rest of physical memory blocks are unused. 
         [0046]      FIG. 9  is a flow chart of management method for reducing the utilization rate of the random access memory in the flash memory according to one embodiment of the present invention. The management method includes the following steps ( 20 ) to ( 27 ): 
         [0047]    ( 20 ) Start. 
         [0048]    ( 21 ) A plurality of physical memory blocks in the flash memory constructs a physical memory set. 
         [0049]    ( 22 ) A plurality of logical blocks constructs a logical set and the data stored in the same logical set are stored in the same physical memory set. The data stored in the amount “n” of logical blocks “LAB 1 ” to “LABN” of the logical set “L” or “L′” are stored in the same physical memory set “S” or “S′”. Further, the data stored in each of the logical blocks “LAB 1 ” to “LABN” are not necessarily stored in a specific number of physical memory blocks. 
         [0050]    ( 23 ) A data-accessing table is defined and located between the logical block and the physical memory set. During the step ( 22 ), a mapping table  10  is defined and located between the physical memory set “S” or “S′” and the logical blocks LAB 1  to LABN. The mapping table  10  includes a hash function  11 , a logical set table  12 , a physical memory set table  13 , and a set status table  14 . 
         [0051]    ( 24 ) The management method determines whether the data are read from or written to the flash memory  100 . If the data are read, proceed to step ( 25 ). If the data are written, proceed to step ( 26 ). 
         [0052]    ( 25 ) The management method writes the data to the flash memory  100  and updates the mapping table  10 . Based on the relationship of the mapping table between the physical memory set “S” or “S′” and the logical blocks, “LAB 1 ” to “LABN”, the data are written to the flash memory  100  and the mapping table  10  is updated. 
         [0053]    ( 26 ) The management method reads the data indices. Based on the relationship of the mapping table between the physical memory set “S” or “S′” and the logical blocks “LAB 1 ” to “LABN”, the management method reads the data from the flash memory  100 . 
         [0054]    ( 27 ) End. 
         [0055]      FIG. 10  is a flow chart of writing data and updating the mapping table according to one embodiment of the present invention. The flow chart in  FIG. 10  shows the detailed procedures in step ( 25 ) of  FIG. 9  and further includes the following steps ( 251 ) to ( 259 ): 
         [0056]    ( 251 ) Start. 
         [0057]    ( 252 ) The host issues an access command to access the flash memory and assigns a specific logical block address. That is, the host issues the access command and writes the accessed data to at least one of the logical blocks “LAB 1 ” to “LABN”. 
         [0058]    ( 253 ) The management method inquires the mapping table  10  to identify the corresponding physical memory set based on the logical block address. In other words, based on the logical addresses “LA 1 ” to “LAN” from the logical blocks “LAB 1 ” to “LABN” in step ( 252 ), the management method inquires the mapping table  10  to identify the physical memory set “S” or “S′”. 
         [0059]    ( 254 ) The management method determines whether unused physical memory blocks are located in the physical memory set “S” or “S′”. If yes, proceed to step  255 , and if no, proceed step  2541 . 
         [0060]    ( 2541 ) The management method searches at least one unused physical memory set. That is, the management method searches the unused physical memory set “S′”, as shown in  FIG. 4 . 
         [0061]    ( 2542 ) The management method copies the effective data of the physical memory block in the original physical memory set to the unused physical memory set and releases the original physical memory set. In other words, the management method copies the effective data stored in the physical memory block “PA 1 ” to “PAM” of the physical memory set “S” to the physical memory blocks “PB 1 ” to “PBM” of the unused physical memory set “S′” during the step ( 2541 ). 
         [0062]    ( 255 ) The management method acquires at least one unused physical memory block in the physical memory set. That is, during the step ( 2542 ) or ( 253 ), the management method acquires unused one of physical memory blocks “PB 1 ” to “PBM” in the unused physical memory set “S′”. 
         [0063]    ( 256 ) The management method writes the data to the physical memory block. That is, the management method writes the data to unused one of the physical memory blocks “PB 1 ” to “PBM” during step ( 255 ). 
         [0064]    ( 257 ) The management method updates the mapping table. That is, the management method updates the hash function  11 , the logical set table  12 , the physical memory set table  13 , and the set status table  14  of the mapping table  10 . 
         [0065]    ( 258 ) End. 
         [0066]      FIGS. 11A-11B  are detailed flow charts of writing the updated mapping table according to one embodiment of the present invention. The flow chart in  FIGS. 11A-11B  show the detailed procedures in step ( 257 ) of  FIG. 10  and further includes the following steps ( 281 ) to ( 294 ): 
         [0067]    ( 281 ) Start. 
         [0068]    ( 282 ) The host issues an access command to access the flash memory and writes the data to an assigned logical block address or updates the data stored in a logical block address. 
         [0069]    ( 283 ) The hash function operates the logical block address to generate the logical set number and the inter-set number. 
         [0070]    ( 284 ) Based on the logical set number the management method inquires the logical set table  12  in the random access memory for generating the physical memory set number “SN” corresponding to the logical block address. 
         [0071]    ( 285 ) Based on the physical memory set number, the management method inquires the physical memory set table  13  for generating the set status index of the physical memory set. 
         [0072]    ( 286 ) Based on the set status index, the management method inquires the invariant set status table  14  for generating the status presentation sequence of the physical memory set. 
         [0073]    ( 287 ) The management method determines whether at least one unused physical memory block is located in the physical memory sets. If no, proceed to step  288 , and if yes, proceed step  291 . 
         [0074]    ( 288 ) The management method searches one unused physical memory set. 
         [0075]    ( 289 ) The management method copies the effective data of the physical memory block in the original physical memory set to the unused physical memory set, releases the original physical memory set, and updates the logical set table and the physical memory set table. 
         [0076]    ( 290 ) The management method searches unused one of the physical memory blocks in the unused physical memory set. 
         [0077]    ( 291 ) The new data are written to the unused one of the physical memory blocks. 
         [0078]    ( 292 ) Based on the updated set status, a status presentation sequence is constructed. 
         [0079]    ( 293 ) The management method updates the physical memory set table. 
         [0080]    ( 294 ) End. 
         [0081]      FIGS. 12A-12B  are detailed flow charts of reading the data indices according to one embodiment of the present invention. The flow charts in  FIGS. 12A-12B  shows the detailed procedures in step ( 26 ) of  FIG. 9  and further includes the following steps ( 261 ) to ( 269 ): 
         [0082]    ( 261 ) Start. 
         [0083]    ( 262 ) The host issues an access command to access the flash memory and reads the data from an assigned logical block address. 
         [0084]    ( 263 ) The hash function operates the logical block address to generate the logical set number and the inter-set number. That is, the hash function  11  in the mapping table  10  makes an operation to generate the logical set number  111  and the inter-set number  112 . 
         [0085]    ( 264 ) Based on the logical set number, the management method inquires the logical set table  12  in the random access memory for generating the physical memory set number corresponding to the logical block address. That is, based on the logical set number  111  in step ( 263 ), the management method inquires the logical set table  12  in the random access memory for generating the physical memory set number “SN”. 
         [0086]    ( 265 ) Based on the physical memory set number, the management method inquires the physical memory set table  13  for generating the set status index of the physical memory set. That is, based on the physical memory set number “SN”, the management method inquires the physical memory set table  13  for generating the set status index “SI”. 
         [0087]    ( 266 ) Based on the set status index, the management method inquires the invariant set status table  14  for generating the status presentation sequence of the physical memory set. That is, based on the set status index “SI” in step ( 265 ), the management method inquires the set status table  14  for generating the status presentation sequence  141 . 
         [0088]    ( 267 ) The management method searches the status presentation sequence to determine whether at least one value of the status presentation element in the status presentation sequence is the same as the inter-set number  112  in the sets. If yes, proceed step  268 , and if no, proceed to step ( 2671 ). 
         [0089]    ( 2671 ) The management method reports errors or returns the data size of an empty block and proceeds to step ( 269 ). 
         [0090]    ( 268 ) If the value in the status presentation element “i-th” is the same as the inter-set number, the management method reads the data on the block “i-th” and returns the data. 
         [0091]    ( 269 ) End. 
         [0092]    As is understood by a person skilled in the art, the foregoing preferred embodiments of the present invention are illustrative rather than limiting of the present invention. It is intended that they cover various modifications and similar arrangements be included within the spirit and scope of the appended claims, the scope of which should be accorded the broadest interpretation so as to encompass all such modifications and similar structure.