Changes between Version 8 and Version 9 of AtomicOperations


Ignore:
Timestamp:
Oct 12, 2010, 3:58:10 PM (14 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AtomicOperations

    v8 v9  
    1313
    1414The TSAR memory sub-system supports the LL/SC mechanism. The LL & SC commands are defined in the VCI/OCP protocol, and the LL and SC instructions must be defined in the processor Instructon Set Architecture. This is natively the case for the MIPS32 & PowerPC processors.
    15 On the direct network, the VCI CMD field can take four values : READ, WRITE, LINKED_LOAD (LL), and STORE_CONDITIONAL (SC). From a conceptual point of view, the atomicity his handled on the memory controller side (actually the memory cache controllers), as the memory controllers must maintain a list of all pending atomic operations in a ''reservation table'' :
     15On the direct network, the VCI CMD field can take four values : READ, WRITE, LINKED_LOAD (LL), and STORE_CONDITIONAL (SC). From a conceptual point of view, the atomicity his handled on the memory controller side (actually the memory cache controller), as the memory controllers must maintain a list of all pending atomic operations in a ''reservation table'' :
    1616
    17  * When a processor, identified by its SRCID, executes the LL(X) instruction to an address X, the memory controller registers an entry (SRCID, X) in the reservation table, and returns the memory value stored at address X in the VCI RDATA field. If there was another reservation for the same processor SRCID, but for another address X’, the previous reservation for X’ is lost (it means that the previous reservation can be cancelled).
     17 * When a processor, identified by its SRCID, executes the LL(X) instruction to an address X, the memory controller registers an entry (SRCID, X) in the reservation table, and returns the memory value stored at address X in the VCI RDATA field. If there was another reservation for the same processor SRCID, but for another address X’, the previous reservation for X’ is lost (it means that the previous reservation is cancelled).
    1818 * When a processor, identified by its SRCID, executes the SC(X) instruction, there is two possibilities. If there is a valid reservation entry (SRCID, X) indicating that no other access to the X address has been received, the atomic operation is a success : the write is done, the memory cache controller returns a “true” value in he RDATA VCI field, and all entries in the reservation table for the X address are cancelled. If there is no valid reservation entry (SRCID, X) in the reservation table, the atomic operation is a failure : The write is not done, and the memory cache returns a “false” value in the RDATA field.
    1919
    2020Clearly, in case of concurrent access, the winner is defined by the first SC instruction received by the memory controller.
    2121
    22 As described below, this mechanism can be used to implement a spin-lock, using any memory address :
     22As described below (using MIPS32 instruction set), this mechanism can be used to implement a spin-lock, using any memory address :
    2323 * The lock acquisition is done by an atomic LL/SC operation.
    2424 * The lock release is done by a simple WRITE instruction.
     
    2727                        _itmask                 # enter critical section
    2828# lock acquisition
    29 loop                    LL Reg1 @               # Reg1 <= M[@]
    30                         BNE Reg1 loop           # continue if lock not taken (Reg1 == 0)
    31                         SC  1 @                 # M[@] <= 1 / Reg2 <= KO
    32                         BNE Reg2 loop           # retry if not atomic (Reg2 != 0)
     29loop                    LL r1,   0(r4)          # r1 <= M[r4]
     30                        BNEZ r1, loop           # retry if lock already taken (r1 != 0)
     31                        ORI r1,  r0, 1          # r1 <= 1
     32                        SC  r1,  0(r4)          # if atomic (M[r4] <= 1 / r1 <= 1) else (r1 <= 0)
     33                        BEQZ r1, loop           # retry if not atomic (r1 == 0)
    3334                        ...
    3435# lock release
    35                         SW 0 @                  # M[@] <= 0
     36                        ORI r1, r0, 0           # r1 <= 0
     37                        SW r1, 0(r4)            # M[r4] <= 0
    3638                        _itunmask               # exit critical section
    3739}}}
     
    3941== 3.  Cachable atomic operations ==
    4042
    41 In order to support cachable spin-locks and a better scalability, the memory cache controller, and the L1 cache controller must cooperate to implement the LL/SC mechanism. But the previous semantic of the LL/SC mechanism has to be modified.
     43In order to support cachable spin-locks and a better scalability, the memory cache controller, and the L1 cache controller must cooperate to implement the LL/SC mechanism. But the standard semantic of the LL/SC mechanism has to be modified.
    4244
    4345Furthermore, the LL/SC mechanism is extended to support both 32 and 64 bits atomic accesses.