21 | | From a conceptual point of view, the atomicity is handled on the memory controller side, that is actually the L2 cache controller in the TSAR architecture. Each L2 cache controller contains a list of all pending LL/SC atomic operations in an associative ''reservation table'', that contains 32 entries. Cette table doit enregistrer l'adresse X. Elle n'a pas besoin d'enregistrer le(s) numéro(s) des clients, mais elle doit identifier l'opération LL/SC pour éviter que deux opérations (LL/SC) à la même adresse X ne se mélangent. |
22 | | * When a processor P executes the LL(X) instruction for an address X, this réservation request is sent to the L2 cache by the L1 cache. The L2 cache allocates a 32 bits authentication key for this reservation. It registers both the X address and the K key in the associative ''reservation table'', and returns both the value stored at address X and the K value to the L1. Both the X address and the K key are also registered in the L1 cache. If another processor P' request a reservation for the same address X, it receives the saved K value from the L2 cache. |
| 21 | From a conceptual point of view, the atomicity is handled on the memory controller side, that is actually the L2 cache controller in the TSAR architecture. Each L2 cache controller contains a list of all pending LL/SC atomic operations in an associative ''reservation table'', that contains 32 entries. Each entry registers the X dress, plus a 32 bits K key identifying a given LL/SC operation. It does not register the client identifier, but the K key avoids to mix two successive LL/SC operations with the same address X. |
| 22 | |
| 23 | * When a processor P executes the LL(X) instruction for an address X, this réservation request is sent to the L2 cache by the L1 cache. The L2 cache allocates a 32 bits authentication key for this reservation. It registers both the X address and the K key in the associative ''reservation table'', and returns both the value stored at address X and the K value to the L1. Both the X address and the K key are also registered in the L1 cache. If another processor P' request a reservation for the same address X, it receives the registered K value from the L2 cache. |
24 | | * When a processor P executes the SC(X,D) instruction to an address X, this conditional write is sent to the L2 cache by the L1 cache, and the command contains both the reservation key K and the data D to be written. The L2 cache makes an associative search in the ''reservation table''. If a reservation with the same address X and the same key K is found, the atomic operation is a success : The reservation is canceled in the ''reservation table'', the D value is written at address X, and a ''success'' value is returned to the L1 cache. If there is no match in the ''reservation table'', the atomic operation is a failure: the D value is not written at address X, the ''reservation table'' is not modified, and a ''failure'' value is returned to the L1 cache. |
| 25 | * When a processor P executes the SC(X,D) instruction to an address X, this conditional write is sent to the L2 cache by the L1 cache, and the command contains both the reservation key K and the data D to be written. The L2 cache makes an associative search in the ''reservation table''. If a valid reservation with the same address X and the same key K is found, the atomic operation is a success : The reservation is canceled in the ''reservation table'', the D value is written at address X, and a ''success'' value is returned to the L1 cache. If there is no match in the ''reservation table'', the atomic operation is a failure: the D value is not written at address X, the ''reservation table'' is not modified, and a ''failure'' value is returned to the L1 cache. |
70 | | In the TSAR architecture, the memory cache controller returns the value 0 for a success, and the value 1 for a failure to a SC(X,D,K) VCI command. |
71 | | If the architecture uses a MIPS or ARM processor, the SC value must be transcoded by the L1 cache controller before |
| 71 | In the TSAR architecture, the L2 cache controller returns the value 0 for a success, and the value 1 for a failure to a SC(X,D,K) VCI command. |
| 72 | If the architecture uses a MIPS or ARM processor, the value returned by the L2 cache must be transcoded by the L1 cache controller before |
84 | | loop LL r1, 0(r4) # r1 <= M[r4] |
85 | | BNEZ r1, loop # retry if lock already taken (r1 != 0) |
86 | | ORI r1, r0, 1 # r1 <= 1 |
87 | | SC r1, 0(r4) # if atomic (M[r4] <= 1 / r1 <= 1) else (r1 <= 0) |
88 | | BEQZ r1, loop # retry if not atomic (r1 == 0) |
| 85 | loop ll r1, 0(r4) # r1 <= M[r4] |
| 86 | bnez r1, loop # retry if lock already taken (r1 != 0) |
| 87 | ori r1, r0, 1 # r1 <= 1 |
| 88 | sc r1, 0(r4) # if atomic (M[r4] <= 1 / r1 <= 1) else (r1 <= 0) |
| 89 | beqz r1, loop # retry if not atomic (r1 == 0) |