Buffer managing method and buffer controller thereof

By assigning a slave unit and at least one master unit in a buffer controller, clocks of the at least one master unit can be unified with a clock of the slave unit. A buffer status array is assigned for the slave unit in a buffer, and either a range status array or a queue status array is assigned for the master unit in the buffer for performing operations of the buffer controller in an accessing-by-block manner or in an accessing-by-spaced-interval manner. The master unit cooperated with the slave unit is determined from the at least one master unit by using a starvation-preventing algorithm.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a buffer managing method and a buffer controller thereof, and more particularly, to a buffer managing method of synchronizing units of a buffer controller and the buffer controller thereof.

2. Description of the Prior Art

Buffer controlling related to mass data processing is always an important issue, where the mass data includes multimedia data streams. For buffering the mass data, different high-speed interfaces and drivers of different operating systems are also utilized in a buffer controller.

However, using the different interfaces and drivers may introduce compatibility-related issues in the buffer controller as well, for example, asynchronous clocks of different elements in a single buffer controller. Please refer toFIG. 1, which schematically illustrates a conventional buffer controller100and how it cooperates with a host110and a flash memory120, for explaining the compatibility-related issues mentioned above.

As shown inFIG. 1, the buffer controller100serves as a bridge between the host110and the flash memory120in data transmission, where the buffer controller100and the flash memory120may be disposed in a same hardware device. The buffer controller100includes an interface130, a data processing unit140, a rear processing engine150, a micro processor160, and a buffer170.

The interface130is utilized for receiving data from the host110in correspondence with an operating system utilized by the host110. The data processing unit140is utilized for processing data received by the interface130. The rear processing engine150is utilized for checking the data processed by the data processing unit140, such as error correction so that correctness of the data transmitted to the flash memory120can be ensured. The micro processor160is utilized for coordinating operations of the interface130, the data processing unit140, the rear processing engine150, and the buffer170, where the buffer170is utilized for buffering process variables or information for the micro processor160.

As can be observed fromFIG. 1, if the interface130, the data processing unit140, the rear processing engine150, the micro processor160, and the buffer170are operated under a plurality of asynchronous clocks respectively, correctness of data processed by the elements of the buffer100may be significantly decreased.

SUMMARY OF THE INVENTION

The claimed invention discloses a buffer managing method. The buffer managing method comprises receiving a datum from a host to a physical memory segment of a buffer of a buffer controller when a buffer status slot mapping the physical memory segment indicates allowance of modifying the physical memory segment and when an accessing-by-block status slot corresponding to the buffer status slot indicates that the physical memory segment is a current datum receiving target; and outputting a datum from the physical memory segment to a flash memory when the buffer status slot mapping the physical memory segment indicates disallowance of modifying the physical memory segment and when the accessing-by-block status slot corresponding to the buffer status slot indicates that the physical memory segment is a current datum outputting source. The buffer status slot is an element of a buffer status array. The accessing-by-block status slot is an element of an accessing-by-block status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of continuous buffer status slots in the buffer status array at a time.

The claimed invention discloses a buffer managing method. The method comprises receiving a datum from a host to a physical memory segment of a buffer of a buffer controller when a buffer status slot mapping the physical memory segment indicates allowance of modifying the physical memory segment and when an accessing-by-spaced-interval status slot corresponding to the buffer status slot indicates that the physical memory segment is a current datum receiving target; and outputting a datum from the physical memory segment to a flash memory when the buffer status slot mapping the physical memory segment indicates disallowance of modifying the physical memory segment and when the accessing-by-spaced-interval status slot corresponding to the buffer status slot indicates that the physical memory segment is a current datum outputting source. The buffer status slot is an element of a buffer status array. The accessing-by-spaced-intervals status slot is an element of an accessing-by-spaced-interval status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of spaced-by-interval buffer status slots in the buffer status array.

The claimed invention discloses a buffer managing method. The buffer managing method comprises moving a datum from a first physical memory segment of a buffer of a buffer controller to a second physical memory segment of the buffer when an accessing-by-block status slot corresponding to a first buffer status slot mapping the first physical memory segment indicates that the first physical memory segment is a current source of a data moving instruction for moving the datum and when an accessing-by-spaced-interval status slot corresponding to a second buffer status slot mapping the second physical memory segment indicates that the second physical memory segment is a current target of the data moving instruction. Both the first and second buffer status slots are elements of a buffer status array. The accessing-by-block status slot is an element of an accessing-by-block status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of continuous buffer status slots in the buffer status array at a time. The accessing-by-spaced-intervals status slot is an element of an accessing-by-spaced-interval status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of spaced-by-interval buffer status slots in the buffer status array.

The claimed invention discloses a buffer managing method. A buffer managing method comprises accessing a datum buffered at a physical memory segment of a buffer according to a data moving instruction, when a first slot in an accessing-by-spaced interval status slot corresponding to a second slot of a buffer status array mapping a physical memory segment of a buffer indicates that the physical memory segment is allowed to be accessed, and when a third slot in an accessing-by-block status slot corresponding to the second slot of the buffer status array indicates that the physical memory segment is allowed to be accessed. The buffer status slot is an element of a buffer status array. The accessing-by-block status slot is an element of an accessing-by-block status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of continuous buffer status slots in the buffer status array at a time. The accessing-by-spaced-intervals status slot is an element of an accessing-by-spaced-interval status array utilized for accessing a plurality of physical memory segments mapped by a corresponding plurality of spaced-by-interval buffer status slots in the buffer status array.

The claimed invention further discloses a buffer controller. The buffer controller comprises a buffer, at least one master unit, and an arbitration module. The buffer is utilized for storing a plurality of physical memory segments, a buffer status array having a plurality of buffer status slots mapping to the plurality of physical memory segments, an accessing-by-block status array having a plurality of accessing-by-block status slots corresponding to the plurality of buffer status slots, and an accessing-by-spaced-interval status array having a plurality of accessing-by-spaced-interval status slots corresponding to the plurality of buffer status slots. The at least one master unit is utilized for accessing the buffer. The arbitration module is utilized for determining a master unit among the at least one master unit by using a starvation-preventing algorithm when the buffer controller executes an instruction.

DETAILED DESCRIPTION

For neutralizing the asynchronous clock issue between elements of

the buffer controller100, the present invention discloses a buffer managing method which can be implemented on a buffer controller.

Please refer toFIG. 2, which illustrates a buffer controller200for implementing the buffer managing method of the present invention. In comparison to the buffer controller100shown inFIG. 1, the buffer controller200further has an arbitrator module180, and has a data processing unit240implemented by the buffer managing method of the present invention for replacing the data processing unit140.

InFIG. 2, the buffer170acts as a slave unit, whereas the interface130, the micro processor160, and the rear processing engine150act as master units, so that the clocks utilized by the interface130, the micro processor160, and the rear processing engine150can be synchronous with a clock utilized by the buffer170. One of purposes of the disclosed buffer management method is to render the buffer170to be the center of synchronizing operations of the interface130, the micro processor160, and the rear processing engine150. The arbitrator module180is configured to pick one of the master units when at least one of the interface130, the micro processor160, and the rear processing engine150competes for resources of the buffer170, i.e. the slave unit. In one embodiment of the present invention, a Round-Robin algorithm is utilized for implementing the arbitration mechanism of the arbitrator module180; however, in other embodiments of the present invention, other starvation-preventing algorithms may also be utilized for implementing the arbitration mechanism of the arbitrator module180, so as to prevent any one of the master units from waiting for accessing the resources of the buffer170for a long period of time.

A specific memory segment is assigned in the buffer170for indicating current statuses of other memory segments in the buffer170; a status of a memory segment in the buffer170may include whether the memory segment can be currently written, read, or neither.

With the aid of the slave unit, i.e. the buffer170, clocks of the slave unit and the master units within the buffer controller200can be coordinated, however, the coordination provided by the buffer170still requires a buffer managing method disclosed in the present invention for implementation.

The following diagrams are utilized for explaining how the disclosed buffer management method works under different conditions.

Please refer toFIG. 3, which illustrates an exemplary memory scheme for indicating statuses of physical memory segments in the buffer170. InFIG. 3, a range status array RSA and a queue status array QSA are established in the buffer170for indicating next-step statuses of (N+1) slots M0, M1, M2, M3, M4, M5, M6, M7, M8, M9, . . . , and MN of a buffer status array MSA established in the buffer170also, where the (N+1) mapping slots M0, M1, . . . , and MN map (N+1) physical memory segments in an one-by-one manner, and where N indicates a positive integer. Note that the (N+1) physical memory segments mapped by the (N+1) slots M0, M1, . . . , and MN are not necessarily continuous in the buffer170. The range status array RSA includes (N+1) slots R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, . . . , and RN, and has a one-by-one mapping with mapping slots of the buffer status array MSA and with the physical memory segments one-by-one mapped by the buffer status array MSA. Similarly, the queue status array QSA also includes (N+1) slots Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, . . . , and QN, and has a one-by-one mapping with mapping slots of the buffer status array MSA and with the physical memory segments one-by-one mapped by the buffer status array MSA. For example, the range status of the slot M5can be uniquely determined by the current value of the slot R5; similarly, the queue status of the slot M5is also uniquely indicated by the value of the slot Q5. In one embodiment of the present invention, values of the above-mentioned slots in the buffer status array MSA, the queue status array QSA, and the range status array RSA may be 0 or 1, i.e. binary.

There are certain rules for the memory scheme shown inFIG. 3as follows:(a) One-by-one mapping between the buffer status array MSA and the range status array RSA, and the one-by-one mapping between the buffer status array MSA and the queue status array QSA. Besides, a slot having value 0 in the buffer status array MSA indicates that the slot is allowed to be written and its value is updated to 1 after being written; a slot having value 1 in the buffer status array MSA indicates that the slot is allowed to be read and its value is updated to be 0 after being read.(b) The value 0 in one slot of the range status array RSA indicates prohibition of access to a corresponding physical memory segment, whereas the value 1 in the slot of the range status array RSA indicates allowance of modifying a physical memory segment mapped by a corresponding slot in the buffer status array MSA; after writing data to a physical memory segment, the value of the corresponding slot in the buffer status array MSA is updated to 1; and after reading data from a physical memory segment, the value of the corresponding slot in the buffer status array MSA is updated to 0. Besides, when the range status array RSA is utilized for indicating access states to corresponding physical memory segments, the corresponding physical memory segments are indicated by a plurality of continuous slots in the buffer status array MSA, as illustrated by the range status array RSA inFIG. 5.(c) The value 0 or 1 in one slot of the queue status array QSA is defined by the same definitions as the range status RSA. However, unlike the usage of the range status array RSA, when the queue status array QSA is utilized for indicating access states to corresponding physical memory segments, the corresponding physical memory segments are indicated by a plurality of discontinuous (i.e. discrete) slots in the buffer status array MSA, as illustrated by the queue status array QSA inFIG. 6.(d) Physical memory segments mapped by slots of the buffer status array MSA may have different sizes from each other.(e) Only one among the range status array RSA and the queue status array QSA is referred at a time when reading or writing physical memory segments.(f) Memory wrapping is utilized by the buffer status array MSA, the range status array RSA, and the queue status array QSA.

Please refer toFIG. 4, which explains the concept of memory wrapping indicated in the topic (f). InFIG. 4, there are a plurality of exemplary and continuous memory addresses S0, S1, . . . , and S9. When the plurality of memory address S0, S1, . . . , and S9are accessed by memory wrapping, it means accessing the memory addresses S0, S1, . . . , and S9in an in-order, cyclic, and block-by-block manner. For example, four continuous memory addresses can be a unit of processing at one time, and the memory address S7is assumed to be a current starting address of accessing; then, performing the memory wrapping means accessing the memory addresses in an order of (S7, S8, S9, S0), (S1, S2, S3, S4), (S5, S6, S7, S8), (S9, S0, S1, S2), . . . , etc.

The buffer managing method of the present invention is performed based on the memory scheme shown inFIG. 3and has a basic flow including:(T1) Determine using the range status array RSA or using the queue status array QSA.(T2) Set the determined status array, and determine a size of physical memory segments to be accessed at one time according to a current system requirement.(T3) Determine a direction of using the determined status array and the buffer status array MSA for accessing corresponding physical memory segments.(T4) Set an initial front pointer.

Based on the above base steps (T1)-(T4), the buffer managing method of the present invention may be utilized for different conditions as follows:(A) Read or write physical memory segments by using the range status array RSA.(B) Read or write physical memory segments by using the queue status array QSA.(C) Data moving by using both the range status array RSA and the queue status array QSA.(D) Partial valid data moving by using both the range status array RSA and the queue status array QSA.

The above-mentioned conditions will be explained and illustrated as follows:

(A) Read or Write Physical Memory Segments by Using the Range Status Array RSA:

By following the above-mentioned basic flow, when a master unit is chosen by the slave unit, i.e. by the data processing unit140, the range status array RSA is selected and set according to the steps (T1) and (T2).

Please refer toFIG. 5, which illustrates the condition (A) according to one embodiment of the present invention. The initial values in the range status array RSA and the buffer status array MSA are shown in the left side ofFIG. 5. It is assumed that a read instruction is first received by the data processing unit140and then a write instruction is received by the data processing unit140. Note that only the slots in the buffer status array MSA indicated by slots having the value 1 in the range status array RSA are updated, as indicated by the allowance of access in the rule (b), whereas the slots in the buffer status array MSA indicated by slots having the value 0 in the range status array RSA are not updated, as indicated by the prohibition of access mentioned in the rule (b).

When the read instruction is first met, the physical memory segments mapped by the slots having value 1 in the buffer status array MSA indicated by slots having value 1 in the range status array RSA are allowed to be read this time, according to the rules (a) and (b), the values of slots in the buffer status array MSA indicated by slots having value 1 in the range status array RSA are all updated to 0 after said physical memory segments are read; values of slots in the buffer status array MSA indicated by slots having value 0 in the range status array RSA are kept under the read instruction, and the physical memory segments mapped by the slots having the kept values in the buffer status array MSA are not allowed to be read at this time.

Then, when the write instruction is met, the physical memory segments mapped by the slots having value 0 in the buffer status array MSA indicated by the slots having value 1 in the range status array RSA are allowed to be written at this time, according to the rules (a) and (b), the values of slots in the buffer status array MSA mapped by the slots having the value 1 in the range status array RSA are all updated to 1 after said physical memory segments are written; the values of the slots in the buffer status array MSA indicated by the slots having the value 0 in the range status array RSA are still kept, and the physical memory segments mapped by the slots having the kept values in the buffer status array MSA are not allowed to be written at this time.

As can be observed inFIG. 5, slots having the value 1 in the range status array RSA are continuous, and so are slots having the value 0 in the range status array RSA. It indicates the fact that in each write or read instruction using the range status array RSA, the corresponding updated slots in the buffer status array MSA are also continuous, i.e., the buffer status array MSA acts as an accessing-by-block array, where a length of the continuous updated slots in the buffer status array MSA, i.e. a range of using the range status array RSA, can also be determined before using the range status array RSA; therefore, a front pointer FP1and a rear pointer RP1can be assigned to the begin slot and the end slot of the range on the buffer status array MSA while performing the read/write instruction by using the range status array RSA, as shown inFIG. 5. Both the front pointer FP1and the rear pointer RP1should be assigned according to an accessing direction of the buffer status array MSA. Note that the above-mentioned memory wrapping, i.e. the rule (f), can also be utilized on the range of using the range status array RSA when the range exceeds the bottom of the buffer status array MSA. At the end of a write/read instruction, the last slot in the buffer status array MSA is assigned to be pointed by the rear pointer RP1so that said last slot can be re-assigned to be pointed by the front pointer FP1when a next write/read operation is met.

(B) Read or Write Physical Memory Segments by Using the Queue Status Array QSA:

By following the above-mentioned basic flow, when a master unit is occupied by the slave unit, i.e. by the data processing unit140, the queue status array QSA is selected and set according to the steps (T1) and (T2).

Please refer toFIG. 6, which illustrates the condition (B) according to one embodiment of the present invention. The initial values in the queue status array QSA and the buffer status array MSA are shown in the left side ofFIG. 6. It is assumed that a read instruction is first received by the data processing unit140and then a write instruction is received by the data processing unit140. Note that the slots in the buffer status array MSA indicated by slots having the value 1 in the queue status array QSA are allowed to be accessed, whereas the slots in the buffer status array MSA indicated by slots having the value 0 in the queue status array QSA are forbidden to be accessed, as indicated by the rule (c).

When the read instruction is first met, the physical memory segments mapped by the slots having value 1 in the buffer status array MSA indicated by slots having the value 1 in the queue status array QSA are allowed to be accessed, i.e. read, according to the rules (a) and (c), the values of slots in the buffer status array MSA indicated by the slots having value 1 in the queue status array QSA are all updated to 0 after said physical memory segments are accessed, i.e. read; the physical memory segments mapped by slots having values 0 or 1 in the buffer status array MSA indicated by slots having the value 0 in the queue status array QSA are not allowed to be accessed, i.e. not allowed to be read.

Then, when the write instruction is met, the physical memory segments mapped by the slots having value 0 in the buffer status array MSA indicated by slots having the value 1 in the queue status array QSA are allowed to be accessed, i.e. written, according to the rules (a) and (c), the values of slots in the buffer status array MSA indicated by the slots having the value 1 in the queue status array QSA are all updated to 1 after said physical memory segments are accessed, i.e. written; the physical memory segments mapped by slots having values 0 or 1 in the buffer status array MSA indicated by slots having the value 0 in the queue status array QSA are not allowed to be accessed, i.e. not allowed to be written.

As can be observed inFIG. 6, slots having the value 1 in the queue status array QSA are not continuous, i.e., the queue status array QSA acts as an accessing-by-spaced-interval status array since each neighboring pair of slots having the value 1 in the queue status array QSA are spaced by a constant amount of slots having the value 0 in the queue status array QSA. Both a front pointer FP2and a rear pointer RP2are also assigned in the queue status array QSA while meeting a write/read instruction by using the queue status array QSA. Except for the range utilized in the range status queue RSA, how the front pointer FP2and the rear pointer RP2are utilized, how a direction of accessing the buffer status array MSA is determined according to both the front pointer FP2and the rear pointer RP2, and how the memory wrapping is utilized are similar to those described when using the range status array RSA, and the related details are not repeatedly disclosed.

By using the queue status array QSA to read or write data, data can be read or written in a discrete manner for better memory shuffling, without modifying contents of physical memory segments that are not allowed to be modified.

(C) Internal Data Moving by Using Both the Range Status Array RSA and the Queue Status Array QSA:

When performing internal data moving of the physical memory segments mapped by the buffer status array MSA, each internal data moving instruction includes a slot in the range status array RSA as a source, and includes a slot in the queue status array QSA as a target. Note that the source and target cannot indicate to a same slot in the buffer status array MSA since it cannot move data on a same physical memory segment mapped by the same slot in the buffer status array MSA as a source and a target simultaneously. Note that a front pointer and a rear pointer may also be set and updated for the internal data moving instruction for the buffer status array MSA to indicate the source and the target of the internal data moving instruction.

Please refer toFIG. 7, which schematically illustrates how data moving is performed using the range status array RSA, the queue status array QSA, the buffer status array MSA, and a physical memory region PHM including a plurality of physical memory segments D0, D1, D2, D3, D6, D9, and D12respectively mapped by slots M0, M1, M2, M3, M6, M9, and M12in the buffer status array MSA, where the physical memory region PHM is disposed in the buffer170. In one embodiment of the present invention, each of the physical memory segments in the physical memory region PHM, for example, each of the physical memory segments D0, D1, D2, D3, D6, D9, and D12, has a size of 512 bytes; however, in other embodiments of the present invention, a size of each of the physical memory segments in the physical memory region PHM is adjustable. As can be observed inFIG. 7, only three slots R0, R1, and R2having the value 1 in the range status array RSA indicate sources of internal data moving instructions, only four slots Q3, Q6, Q9, and Q12having the value 1 in the queue status array QSA indicate targets of the internal data moving instructions.

The mappings from the sources indicated by the range status array RSA to the targets indicated by the queue status array QSA are utilized in an in-order and memory-wrapping manner. Therefore, there will be four internal data moving instructions inFIG. 7: a first instruction is defined by the slots R0and Q3and is configured to move a datum from the physical memory segment D0to the physical memory segment D3; a second instruction is defined by the slot R1and Q6and is configured to move a datum from the physical memory segment D1to the physical memory segment D6; a third instruction is defined by the slot R2and Q9and is configured to move a datum from the physical memory segment D2to the physical memory segment D9; and a fourth instruction is defined by the slots R0and Q12because of the memory wrapping mechanism, and is configured to move a datum from the physical memory segment D0to the physical memory segment D12.

Note that values of the buffer status array MSA are not required to be checked when performing the internal data moving instruction, and the spaces between any two neighboring slots having the value 1 in the queue status array QSA do not necessarily have a same or constant length, as shown inFIG. 7.

By using both the range status array RSA and the queue status array QSA to perform the internal data moving instruction, better memory relocation can be fulfilled.

(D) Partial Valid Data Moving by Using Both the Range Status Array RSA and the Queue Status Array QSA:

While running a partial data moving instruction, the interface130is responsible for data transmission between the host110and the buffer controller200, and the rear processing engine150is responsible for data transmission between the buffer controller200and the flash memory120.

When the partial valid data instruction is configured to transfer data from the host110to the flash memory120, i.e. when the partial valid data instruction is a write instruction, the interface130is configured to receive data from the host110and for buffering the received data into the buffer170, the rear processing engine150is configured to transfer the data from the buffer170to the flash memory120. When the rear processing engine150transfers data from the buffer170to the flash memory120, the queue status array QSA is utilized for indicating valid memory addresses in the buffer170, and the range status array RSA is utilized for determining how many continuous memory addresses of data is to be written into the flash memory120at a time, i.e. for determining a length of memory addresses for writing.

When the partial valid data instruction is configured to transfer data from the flash memory120to the host110, i.e. when the partial valid data instruction is a read instruction, the rear processing engine150is configured to receive data from the flash memory120and for buffering the received data into the buffer170, the interface130is configured to transfer the data from the buffer170to the host110. When the rear processing engine150transfers data from the flash memory120to the buffer170, the range status array RSA is utilized for indicating a length of reading data, i.e., for indicating how many continuous memory addresses of data is to be read, and the queue status array QSA is utilized for indicating valid memory addresses in the buffer170so that the interface130transfers data from the indicated valid memory addresses in the buffer170to the host110. Note that data buffered in invalid memory addresses are restricted from being accessed, i.e., read, while running the partial valid data instruction for reading.

Please refer toFIG. 8, which illustrates how a partial valid data moving instruction works according to one embodiment of the present invention. It is assumed that slots QI0, QI1, QI2, QI3of a queue status array QSA_I correspond to slots M0, M1, M2, M3of the buffer status array respectively, and that slots RR0, RR1, RR2, RR3in a range status array RSA_R correspond to the slots M0, M1, M2, M3of the buffer status array MSA respectively. It is also assumed that the slots M0, M1, M2, M3map to physical memory segments S0, S1, S2, S3of the physical memory region PHM disposed in the buffer170respectively, where the physical memory segments S0, S1, S2, and S3contain data D0, D1, D2, and D3respectively.

When the partial valid data moving instruction is a write instruction, the queue status array QSA indicates a first fact that the physical memory segments S0and S2are valid, and a second fact that the physical memory segments S1and S3are invalid; the range status array RSA_R indicates a length of writing is four, i.e., four continuous memory addresses indicated by the slots RR0, RR1, RR2, RR3at a time. As a result, the data D0, D1, D2and D3are written into the flash memory120since the slots RR0, RR1, RR2, RR3indicate the length of writing, wherein the D1and D3could be dummy datum since the slots QI1and QI3indicate the invalidity of physical memory segments S1and S3.

Similarly, when the partial valid data moving instruction is a read instruction, the physical memory segments S0and S2are read into the host110since the slots QI0and QI2indicate the validity of the physical memory segments S0and S2, whereas the physical memory segments S1and S3are restricted from being accessed since the slots QI1and QI3indicate the invalidity of the physical memory segments S1and S3.

Note that values of the buffer status array MSA are not required to be checked when performing the partial valid data moving, and the spaces between any two neighboring slots having the value 1 in the queue status array QSA do not necessarily have a same or constant length. Besides, the buffer status array MSA is also applied for the abovementioned memory wrapping so that a front pointer and a rear pointer are also utilized according to one embodiment of the present invention.

By restricting invalid physical memory segments of the buffer170from being accessed, performance of the buffer controller200will not be affected by the invalid physical memory segments of the buffer170.

In summary of the abovementioned conditions (A)-(D), with the aid of the range status array RSA and/or the queue status array QSA, the clocks between the slave unit and its corresponding master units can be unified since clocks related to operations of the buffer controller200is based on the clock of the slave unit.

Please refer toFIG. 9, which illustrates a main flow indicating the basic flow including the steps (T1)-(T4). As shown inFIG. 9, the main flow includes steps as follows:

Step302: Select one master unit according to a starvation-preventing algorithm utilized by the arbitrator module180.

Step304: Receive a read instruction, a write instruction, or a data moving instruction.

Step306: Select a range status array, a queue status array, or both for at least one master unit.

Step308: Update a front pointer and a rear pointer for the status array selected in Step306.

Please refer toFIG. 10, which illustrates a writing instruction performed by the buffer controller200according to embodiments of the present invention, as described in the abovementioned conditions (A) and (B). As shown inFIG. 10, the writing instruction includes steps as follows:

Step402: Set a front pointer according to a current target of a rear pointer.

Step404: Search for slots in the buffer status array MSA having the value 0.

Step406: Determine whether to use the range status array RSA or the queue status array QSA.

Step408: Write data of physical memory segments mapped by slots of the buffer status array MSA having the value 0 into the flash memory120according to values of slots in the status array selected in Step404.

Step410: Update values of the slots in the buffer status array MSA found in Step404to be 1.

Step412: Update the target of the rear pointer to be a last target of the writing instruction.

Please refer toFIG. 11, which illustrates a reading instruction performed by the buffer controller200according to embodiments of the present invention, as described in the abovementioned conditions (A) and (B). As shown inFIG. 11, the reading instruction includes steps as follows:

Step502: Set a front pointer according to a current target of a rear pointer.

Step504: Search for slots in the buffer status array MSA having the value 1.

Step506: Determine whether to use the range status array RSA or the queue status array QSA.

Step508: Read data from the host110into physical memory segments mapped by slots of the buffer status array MSA having the value 1 according to values of slots in the status array selected in Step504.

Step510: Update values of the slots in the buffer status array MSA found in Step504to be 0.

Step512: Update the target of the rear pointer to be a last target of the reading instruction.

Please refer toFIG. 12, which illustrates the internal data moving instruction performed by the buffer controller200according to embodiments of the present invention, as described in the abovementioned condition (C). As shown inFIG. 12, the internal data moving instruction includes steps as follows:

Step602: Move a datum from a first physical memory segment to a second physical memory segment when a slot in the range status array RSA corresponding to a first slot of the buffer status array MSA mapping the first physical memory segment has the value 1 and when a slot in the queue status array QSA corresponding to a second slot of the buffer status array MSA mapping the second physical memory segment has the value 1.

Please refer toFIG. 13, which illustrates the partial valid data moving instruction performed by the buffer controller200according to embodiments of the present invention, as described in the abovementioned condition (D). As shown inFIG. 13, the partial valid data moving instruction includes steps as follows:

Step702: Accessing a datum buffered at a physical memory segment of the buffer170when a first slot in the queue status array QSA_I corresponding to a second slot of the buffer status array MSA mapping a physical memory segment has the value 1 and when a third slot in the range status array RSA_R corresponding to the second slot of the buffer status array MSA has the value 1.

Embodiments formed by reasonable combination and permutation of or formed by adding the abovementioned limitations to the steps shown inFIG. 9,FIG. 10,FIG. 11,FIG. 12, andFIG. 13should also be regarded as embodiments of the present invention.

The present invention discloses a buffer managing method and a buffer controller for neutralizing the asynchronous clocks between elements of a conventional buffer controller.