The present invention generally relates to digital systems having multiple processors, and in particular, to a system having multiple processors that have access to a common memory device.
Many digital systems such as hard disk controllers include multiple embedded systems having processors that are operatively connected to a common memory device. Frequently, there are occasions where more than one processor may want access to the same memory location at the same time. It is generally desirable to allow one processor to finish its operation with the memory device before the next one is allowed to take any action, so that the first operation is not interrupted. For example, in a situation where two processors each want to increment a counter, one processor needs to read the current value count, add one and then write it in the counter before the second processor performs its reading operation. Otherwise, if both processors read and write simultaneously, the counter might get incremented only by one, rather than by two as intended.
Where a processor is allowed to perform an operation on a particular memory location without any interruption from other processors is known as an atomic access. In an atomic access, an operation consisting of more than one individual instruction is carried out completely, without any interruption. For example, an operation in which three distinct steps of reading, modifying and then writing data to an address is treated as if it is one operation or step is an atomic access.
The present invention is directed to controlling atomic access to a memory. One embodiment of the invention includes an access request evaluator for receiving an atomic access request to an address in the memory from a client and determining whether to allow atomic access to the requested address. An access indicator indicates whether a select address is currently under atomic access in the memory, and an access release indicates whether the atomic access is completed at the select address. The access request evaluator enables the client atomic access to the requested address if the access indicator indicates that the requested address is currently not under atomic access.
Turning now to
The clients 12 are hardware devices such as processors or state machines which may be embedded in the primary system. The memory device 14 is a data storage device such as a RAM or a flash memory that are capable of having its contents modified. The atomic access controller 18 sends information to the arbitration controller 16 for determining whether an atomic access is issued a grant. The arbitration controller 16 decides which client 12 will have access to the memory device 14, and which request will get serviced by sending a grant or an acknowledgement back to the client.
The arbitration controller 16 is implemented in a logic circuit which is communicatively connected to the clients 12 and the atomic access controller 18. The arbitration controller 16 receives read and write requests from the clients 12 by way of the atomic access controller 18 and grants access to the memory device 14 based on a predetermined method for granting access. In the preferred embodiment, the arbitration controller 16 employs a priority encoded methodology for determining access by the clients 12. As such, a single grant is generated in response to the highest priority request from the clients 12. However, other arbitration schemes may also be used, such as round robin or other known methods. The arbitration controller 16 is implemented in hard-wired logic.
Turning now to
The atomic access release 24 determines when an atomic access to a particular address in the memory device 14 is completed, and clears the atomic access indicator 22. A cleared atomic access indicator 22, informs the atomic access request evaluator 20 that an atomic access resource is available, so that a new atomic owner (of an address in the memory device 14) can be selected. The identity of the client 12 and the address to which the atomic access is requested is stored in the atomic access indicator 22.
More specifically, the atomic access indicator 22 tracks the atomic access in progress with a busy flag, the identity of the client 12 that is conducting the atomic access, and the addresses in the memory device 14 subject to the atomic access. In the preferred embodiment, the busy flag is implemented as a flip-flop element, indicating that an atomic operation is in progress when the flip-flop is asserted. Likewise, the owner of an atomic access may be binary encoded into the minimum number of flip-flop elements necessary to track N clients 12, but could also be one-hot encoded into N flip-flops. The address of the memory device 14 being subject to atomic access is also stored in flip-flops.
The atomic access release 24 implements a comparator circuit (not shown) that compares the write address requested by a client 12 with the read address previously stored in atomic access indicator 22. When the read and write addresses match, and there is an atomic access in progress (as indicated by the busy flag in the atomic access indicator 22), it is concluded that the write request is part of the atomic access. The atomic access release 24 then clears the busy flag in the atomic access indicator 22, indicating that the atomic operation is completed.
As shown in
The atomic access request evaluator 20 also receives write requests from the clients 12. Unlike the handling of read requests, the atomic access request evaluator 20 merely routes the write requests to the arbitration controller 16, without consideration as to whether the write request is for atomic access to the memory 14.
Turning now to
However, if the received read request is an atomic read request, the atomic access request evaluator 20 determines from the atomic access indicator 22 whether there is an atomic access currently in progress (Block 38). If an atomic access is not in progress, the atomic access request evaluator 20 allows the arbitration controller 16 to evaluate the request, and upon successful arbitration, enable the requesting client 12 to access the requested address of the memory device 14 for the read operation (Block 40). The atomic access indicator 22 is also updated to show that the address requested by the client 12 is currently under atomic access (Block 42) and the busy flag is set. If, however, an atomic access is in progress at the requested address (Block 38), the atomic access request evaluator 20 prevents the atomic read request from being presented to the arbitration controller 16 for arbitration, and waits to process the requested atomic access until the current atomic access process ends (Block 44).
Turning now to
The atomic access request evaluator 20 then checks the atomic access indicator 22 to determine whether there is an atomic access currently in progress in the memory device 14 (Block 50). If no atomic access is in progress, the write process is finished.
If, however, there is an atomic access pending, the atomic access release 24 compares the requested write address with the atomic address stored in atomic access indicator 22 to determine whether the requested write address is currently under atomic access (Block 52). If the two addresses do not match, the requested write address is not currently under atomic access, and the write process comes to an end.
However, if a match is detected, the atomic access release 24 clears the busy flag in the atomic access indicator 22 (Block 54) and the write process comes to an end. A match of the two addresses indicates that the write request is a part of the atomic access initiated by the previously received atomic read request. The writing process completes the atomic access, and accordingly, the busy flag is cleared.
While various embodiments of the present invention have been shown and described, it should be understood that other modifications, substitutions and alternatives are apparent to one of ordinary skill in the art. Such modifications, substitutions and alternatives can be made without departing from the spirit and scope of the invention, which should be determined from the appended claims.
Various features of the invention are set forth in the appended claims.