i think the definition of test and set if the test fails the value is not set may have need some correction according to operation system concepts by abraham silberschatz etc in page about the definition of testandset instruction the test and set operations are always executed no matter the test fails or not