Open In App

Atomic Operations in OS

Last Updated : 07 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Atomic operations in Operating System are those operations, which execute without interruption of any other process in between their execution phase. They execute at the lowest level and can’t be broken down further. Formally, when an atomic operation is in its executing process, no other process can read, modify, or interrupt that operation’s data.

These types of operations are used very much in parallel processing where the operations are needed to run without being dependent or interrupted by any other process of an OS. These operations are the backbones of modern Operating Systems, which use parallel processing to execute tasks at a much faster speed. Parallel processing is a very popular method for making modern OS much faster. These atomic operations help to implement parallel processing.

Types of Atomic Operations

There are two types of atomic operations, which small atomic operations and large atomic operations. Let us see the difference between them:

  1. Small Atomic Operation: These types of atomic operations can be implemented without any interruption of any other process. These operations can’t break down more because they are at their smallest level. For example: Loading the value stored in registers or storing the processed value.
  2. Large Atomic Operations: This type of atomic operation consists of a group of small atomic operations. This entire group of operations can’t be interrupted by any other process. For example: Calling a method in a programming language.
Types of Atomic Operations

Types of Atomic Operations

The Atomic operations are much fast in the execution process, which saves system from the occurrence of a deadlock situation. This is a major reason why they are used in modern OS.

Except that they consist of some drawbacks also, which is that they can execute a finite number of processes and fails to execute when the process is much more complicated.

Why Atomic Operations are Needed?

Let us understand this example by relate it to a program of incrementing value of a variable.

  • Initially, considered any variable let’s say A, which has initial value as 0.
  • An increment operation is performed over A, which turns its value to 1. However, this operation is interleaved in between due to any other process, which uses the same variable.
  • That process increments the value of A by 10, which turns the current value of A as 11.
  • Now when inter-leaved operation at point 2 starts executing again from its stopping point, the value of A must be 1 which is now 11, this generated inaccurate results.

If the increment operation at point 2 was performed by an atomic operation, then it doesn’t allow the inter-leaving process and ensures the accuracy of results generated.

FAQs on Atomic Operations

Q.1: Which type of atomic operation is being used regularly?

Answer:

Large atomic operation is used regularly.

Q.2: By whom parallel processing is implemented?

Answer:

Using atomic operations.

Q.3: Give a reason, why we need atomic operations?

Answer:

To maintain the accuracy of calculated results.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads