answersLogoWhite

0

An atomic operation is an operation which is guaranteed to finish in a single unit of time. This is important in synchronization where multiple threads may be trying to access a single variable at the same time.

Theoretically, a situation could occur as follows: Imagine two threads are both running the same code.

int c = 0;

void f() {

c = c + 1;

}

Now assume the following sequence of events takes place:

# Thread0 calls f() # Thread1 calls f() # Thread0 reads c as 0 # Thread1 reads c as 0 # Thread0 increases c to 1 # Thread1 increases c to 1 # Thread0 writes back c as 1 # Thread1 writes back c as 1

We end up with c = 1. This is obviously not what was supposed to happen. Each thread was supposed to execute the code once and increase c by one, ending up with c = 2. If the (c = c + 1) statement had been atomic, each thread would read, increment, and write back c before execution was passed to any other thread.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

Where can I obtain instructions for the operation of a Atomic clock?

http://www.lacrossetechnology.com/8117it/manual.pdf This has the instructions for your atomic clock.


What is operation Trinity?

Trinity was the code name for the explosion of the first atomic bomb in New Mexico in 1945.


What 2 cities in what country had atomic bombs dropped on them during Pacific of Asian Theatre of operation?

Hiroshima and Nagasaki.


Which is the oldest atomic power station in India?

The Tarapur Atomic Power Station in Maharashtra is the oldest nuclear power station in India. It consists of two boiling water reactors that began operation in 1969 and 1969.


What is an atomic clock?

An atomic clock is a reference clock whose operation is based on an atomic process, such as the frequency of electromagnetic radiation associated with a specific energy-level transition in an element such as caesium.


What would have happened if the U.S. did not drop the atomic bomb?

The US would have invaded Japan on 01 Nov 45 Operation: DOWNFALL.


What would have happened if the US had not invented the atomic bomb?

The US would have invaded Japan on 01 Nov 45 Operation: DOWNFALL and fought until victory.


How long did it take to make all three atomic bombs?

As of august 1945 the US had the industrial capacity to make 3 atomic bombs a month. In november 1945 this would increase to 7 atomic bombs a month. As Japan surrendered before this, the US scaled back production and had only made 9 atomic bombs by the end of Operation Crossroads in the summer of 1946, five of which had been detonated.


What was operation Aurora 1945?

operation aurora 1945 was a suicide mission taking place in japan before the atomic bomb went off HOWEVER it is the first mission of BFBC2 in te begin it says it really happened that day and NO the russains did not take over south america


Did operation cardinal ever happen?

"Operation Cardinal" happened. The details of an OSS operation in Mukden, Manchuria, shortly after the surrender of Japan is detailed in an article by Peter Clemens entitled, "Operation Cardinal: The OSS in Manchuria, August 1945." It was published in a journal called Intelligence and National Security (Vol. 13, No. , Winter 1998) Hal Leith, the Russian/Chinese linguist on the mission, is alive and well. I think the questioner is confusing Operation Cardinal with Operation Downfall which was planned for (I believe) November 1945. After the two atomic bombs were dropped on Hiroshima and Nagasaki, and the surrender of Japan less than a week later, Operation Downfall became unnecessary.


How many nuclear power plants does United States have in operation?

Currently, 100 nuclear power plants are operating the United States per the statistics of the International Atomic Energy Agency (IAEA) as of April 2004.


What does the term "atomic" mean in programming and how does it impact the execution of code?

In programming, the term "atomic" refers to an operation that is indivisible and cannot be interrupted. This impacts the execution of code by ensuring that certain operations are completed without interference from other processes, which helps maintain data integrity and prevent race conditions.