Hardware Reference
In-Depth Information
Table 5.2 Difference between TAS and LL/SC
Compared data size
Bus lock
TAS instruction
Binary (zero or nonzero)
LL/SC instructions
32 bits
Not used
1 and reads 4-byte data into a general register. If, however, an interrupt, exception,
or other core's data access occurs, the LL/SC private flag is cleared to 0.
Storage by the SC instruction only proceeds when the instruction is executed
after the LL/SC private flag has been set by the LL instruction and not cleared by an
interrupt, other exception, or other core's data access. When the LL/SC private flag
has been cleared to 0, the SC instruction clears the T-bit in the status register and
does not execute its storage.
The difference between a TAS instruction and LL/SC instructions is indicated in
Table 5.2 .
We describe the atomic add operation using LL/SC instructions. The atomic add
operation needs two arguments: address (call by reference) and value (call by value).
The address argument specifies an address of the variable to be accessed. The value
argument is an immediate value to be added to the variable. The sequences of atomic
add are as follows:
1. Load the data referenced by the address argument to a temporary register using
the LL instruction.
2. Add the value passed by the value argument to the temporary register using a
normal add instruction.
3. Try to store the value of the temporary register to the referenced address using
the SC instruction.
4. Check the condition of the SC instruction's result (T-bit in status register). If
another core's data access occurs between (1) and (3), the SC instruction will
fail, and the value will not be stored to the address. In this case, the above
sequence is retried from the fi rst step.
We evaluate SMP Linux performance of each implementation, using the TAS atomic
operation and LL/SC atomic operation. We use LMBench [ 2 ], which is widely used as
a benchmark program on UNIX-like systems, to compare the performance. The Linux
version on which we have implemented the SMP extension is shown in Table 5.3 .
To compare each implementation, we calculate performance ratio using the follow-
ing formula:
Performance ratio %
{(TASversion) / (LL/SCversion)}
Search WWH ::

Custom Search