0
$\begingroup$

According to the book " Operating Systems Concepts ", ninth edition , page 210, we have the following statement :

Many modern computer systems therefore provide special hardware instructions that allow us either to test and modify the content of a word or to swap the contents of two words atomically—that is, as one uninterruptible unit.

This means that an atomic instruction is an instruction that must run and complete without any interrupts. In the same page, we have :

The test and set() instruction can be defined as shown in Figure 5.3. The important characteristic of this instruction is that it is executed atomically. Thus, if two test and set() instructions are executed simultaneously (each on a different CPU), they will be executed sequentially in some arbitrary order. If the machine supports the test and set() instruction, thenwe can implement mutual exclusion by declaring a boolean variable lock, initialized to false. The structure of process Pi is shown in Figure 5.4.

According to the above statement, we can add another characteristic to the atomic instruction, which is two atomic instructions cannot be executed simultaneously. I think this statement is valid if these two atomic instructions share the same variable lock and this make sense, because if two atomic operations ( like test_and_set()) operates on the same lock variable can be executed at the same time by two processes ( running in parallel on two cores ) and they wish to enter the critical section at the same time , then a race condition can occur. So can we say that an atomic instruction is an instruction that run without any interruptions and cannot run in parallel when it is called on the same lock variable on two or more different cores by two or more different processes or an atomic instruction is the one that cannot be interrupted and to achieve synchronization it should be supplemented by the capability that if two processes call it with the same lock variable then this atomic instruction cannot run on two processor simultaneously ?

$\endgroup$

1 Answer 1

1
$\begingroup$

This is just a matter of wording. “Uninterruptible” implies that the instruction cannot execute in parallel with an identical instruction - that would be the ultimate interruption.

But that’s implementation details. The important thing is that these operations are atomic. That is indivisible. If the description contains multiple parts, then all these parts will happen simultaneously.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.