<P> Whether or not CPU 2 was trying to access the memory location, the DPRAM performs the test given by CPU 1 . If the test succeeds, the DPRAM sets the memory location to the value given by CPU 1 . Then the DPRAM wipes out its "internal note" that CPU 1 was writing there . At this point, CPU 2 could issue a test - and - set, which would succeed . </P> <P> CPU 1 issues a test - and - set instruction to write to "memory location A". The DPRAM does not immediately store the value in memory location A, but instead simultaneously moves the current value to a special register, while setting the contents of memory location A to a special "flag value". If at this point, CPU 2 issues a test - and - set to memory location A, the DPRAM detects the special flag value, and as in Variation 1, issues a BUSY interrupt . </P> <P> Whether or not CPU 2 was trying to access the memory location, the DPRAM now performs CPU 1's test . If the test succeeds, the DPRAM sets memory location A to the value specified by CPU 1 . If the test fails, the DPRAM copies the value back from the special register to memory location A. Either operation wipes out the special flag value . If CPU 2 now issues a test - and - set, it will succeed . </P> <P> Some instruction sets have an atomic test - and - set machine language instruction - x86 and IBM System / 360 and its successors (including z / Architecture). Those that do not can still implement an atomic test - and - set using a read - modify - write or compare - and - swap instruction . </P>

Bounded waiting mutual exclusion with test and set