| the lock prefix applies to a single command, it has no impact on the interruption, because the interruption can only be generated between commands. The true function of the lock prefix is to keep control of the system bus until the entire command is executed. It is quite useful when a command accesses the memory multiple times. for example, if you want to share a counter, perform the atomic increment operation on it. You need to do the following: 1) read the counter value from the memory, temporarily save it in the CPU internal register. 2) Add the read value. 3) write the modified value back to the memory. In the X86 architecture, This incremental operation can be completed in a single command, so interruption does not affect this incremental operation. however, this command has two memory access operations: Read and Write. The other CPU or core may increment the counter at the same time. If another CPU/core (CORE) reads the value of this counter before the completion of step 2 and the completion of step 2, then the two CPU/core (CORE) use the previously modified counter value and increment it. In this case, an error occurs. |