Test-and-set
In computer science, the test-and-set instruction is an instruction used to write (set) a flag value to a memory location and return its old value as a single atomic (i.e., non-interruptible) operation. The caller can then "test" the result to see if the state was changed by the call.