(computer science) An operation that cannot be broken up into smaller parts that could be performed by different processors.
| Sci-Tech Dictionary: atomic operation |
(computer science) An operation that cannot be broken up into smaller parts that could be performed by different processors.
| 5min Related Video: Atomic operation |
| Wikipedia: Atomic operation |
An atomic operation in computer science refers to a set of operations that can be combined so that they appear to the rest of the system to be a single operation with only two possible outcomes: success or failure.
Contents |
A set of operations can be considered atomic when two conditions are met:
Even without the complications of multiple processing units, this can be non-trivial to implement. As long as there is the possibility of a change in the flow of control, without atomicity there is the possibility that the system can enter an invalid state (invalid as defined by the program, a so-called invariant).
For example, imagine a single process is running on a computer incrementing a value in a given memory location. To increment the value in that memory location:
Now, imagine two processes are running incrementing a single, shared memory location:
but before it can write the new value back to the memory location it is suspended, and the second process is allowed to run:
The second process is suspended and the first process allowed to run again:
This is a trivial example. In a real system, the operations can be more complex and the errors introduced extremely subtle. For example, reading a 64-bit value from memory may actually be implemented as two sequential reads of two 32-bit memory locations. If a process has only read the first 32-bits, and before it reads the second 32-bits the value in memory gets changed, it will have neither the original value nor the new value but a mixed-up garbage value.
Furthermore, the specific order in which the processes run can change the results, making such an error difficult to detect and debug.
While an atomic operation is functionally equivalent to a "critical section" (protected by a lock), it requires great care to not suffer significant overhead compared to direct use of atomic operations, with many computer architectures offering dedicated support. To improve program performance, it is therefore often a good idea to replace simple critical sections with atomic operations for non-blocking synchronization, instead of the other way around, but unfortunately a significant improvement is not guaranteed and lock-free algorithms can easily become too complicated to be worth the effort.
Most modern processors have instructions which can be used to implement locking and lock-free and wait-free algorithms. The ability to temporarily turn off interrupts, ensuring that the currently running process cannot be context switched, also suffices on a uniprocessor. These instructions are used directly by compiler and operating system writers but are also abstracted and exposed as bytecodes and library functions in higher-level languages.
Many of these primitives can be implemented in terms of each other.
This entry is from Wikipedia, the leading user-contributed encyclopedia. It may not have been reviewed by professional editors (see full disclaimer)
| atomic (technology) | |
| Atomic time | |
| European Economic Community |
| Derive the kinetic energy operator for a system of 4 atoms using Jacobi coordinates? Read answer... | |
| What do atoms have? Read answer... | |
| What do atoms do? Read answer... |
Copyrights:
![]() | Sci-Tech Dictionary. McGraw-Hill Dictionary of Scientific and Technical Terms. Copyright © 2003, 1994, 1989, 1984, 1978, 1976, 1974 by McGraw-Hill Companies, Inc. All rights reserved. Read more | |
![]() | Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Atomic operation". Read more |