Questions tagged [atomicity]

In concurrent programming, an operation (or set of operations) is atomic, linearizable, indivisible or uninterruptible if it appears to the rest of the system to occur instantaneously. Atomicity is a guarantee of isolation from concurrent processes. Additionally, atomic operations commonly have a succeed-or-fail definition — they either successfully change the state of the system, or have no visible effect.

In concurrent programming, an operation (or set of operations) is atomic, linearizable, indivisible or uninterruptible if it appears to the rest of the system to occur instantaneously. Atomicity is a guarantee of isolation from concurrent processes. Additionally, atomic operations commonly have a succeed-or-fail definition — they either successfully change the state of the system, or have no visible effect.

Atomicity is commonly enforced by mutual exclusion, whether at the hardware level building on a cache coherency protocol, or the software level using semaphores or locks. Thus, an atomic operation does not actually occur instantaneously. The benefit comes from the appearance: the system behaves as if each operation occurred instantly, separated by pauses. Because of this, implementation details may be ignored by the user, except insofar as they affect performance. If an operation is not atomic, the user will also need to understand and cope with sporadic extraneous behaviour caused by interactions between concurrent operations, which by its nature is likely to be hard to reproduce and debug.

Source: Wikipedia

574 questions
0
votes
1 answer

Thread-safe singleton and nonatomic properties issue

I have an issue, described below and solution. But I think our solution is not really "right way" to solve this issue. 1: I have thread safe singleton for Data //DataSingleton.h @interface DataSingleton : NSObject @property (nonatomic, readonly,…
WINSergey
  • 1,734
  • 22
  • 36
0
votes
3 answers

MySQL: Producer/Consumer Model, need atomicity in commands accessing multiple tables

I have the following 2 tables, with sample values: producer_tbl: id (auto-inc, PK) producer_id item_id item_added 2 5 3 20 products_available_tbl: item_id (PK) avail_cnt blocked_cnt 3 …
Ethan
  • 4,512
  • 1
  • 24
  • 32
0
votes
1 answer

Session safety violation in Roller

RollerSession has the following code: public static RollerSession getRollerSession(HttpServletRequest request) { RollerSession rollerSession = null; HttpSession session = request.getSession(false); if (session != null) { …
user1539577
  • 192
  • 1
  • 2
  • 11
0
votes
1 answer

Is it safe to call size on a std container from another thread?

When one thread manages an std::map adding and removing things, may another thread safely call size() on the map? Since there are no iterators involved, invalidation is not an issue. In this case, I suppose the map is always alive. No…
Gabriel
  • 2,390
  • 4
  • 27
  • 41
0
votes
1 answer

.net System.MemberwiseClone and interlocked writes

When performing a MemberwiseClone of an array of value types: var arr = new double[100]; If these doubles are being modified using an Interlocked write on other threads, will the MemberwiseCloned copy be at any risk of having torn doubles in it?…
DanH
  • 3,652
  • 2
  • 25
  • 30
-1
votes
1 answer

Ensure query is atomic

Background In my code below I have a function called process that does some stuff and when it is running i want to make sure it is not run concurrently. I have a table called creation_status where i set a time stamp anytime i start the process. The…
Dinero
  • 767
  • 6
  • 24
-1
votes
1 answer

What is the impact of memory barriers against incrementing code?

Consider the following program: 2 threads are iterating through the same function that consists of incrementing the value of a shared counter variable. There's no lock protecting the variable, as such we're talking about lock-free programming. We're…
-1
votes
1 answer

If compareAndSet fails, is the code below still executed?

I have a very dumb question. If I use AtomicReferences compareAndSet this way original.set(atomic.get()); long next = some new value atomic.compareAndSet(original.get(), next); ....more code.... is more code still updated if the…
Olli
  • 173
  • 1
  • 8
-1
votes
1 answer

Are ldmfd and stmfd atomic?

Do the ldmfd and stmfd keep atomicity if the register list is more than 2? such as stmfd sp!, {r1-r12} ldmfd sp!, {r1-r12} can this be interrupted by events?
-1
votes
2 answers

Multiple threads arrive, the last should do the processing

I'm implementing a logging where multiple threads can write into one List of log. The last thread should write the contents of the List to a file. So the thread which is the last to write into the List should flush the List into a file. What is the…
Roland
  • 6,452
  • 9
  • 52
  • 104
-1
votes
2 answers

Getting an unexpected value in global device memory when multiple threads write to it

Here is problem with cuda threads , memory magament, it returns single threads result "100" but would expect 9 threads result "900". #indudel #include #include #include #include…
Flow
  • 5
  • 6
-1
votes
1 answer

Use and reset an int that is constantly incremented by another thread

I got a Task that counts the number of packets it receives from some source. Every 250ms a timer fires up reads and outputs the count to the user. Right after i need to set the count back to 0. My concern is that between reading and displaying the…
user1957413
  • 105
  • 1
  • 10
-1
votes
1 answer

What is the memory order of JUCE's atomic facilities?

In boost library and C++11 standard library, the atomic operations have memory order modifiers which limit the instruction reorder. However, JUCE's atomic facilities don't have this. So does JUCE atomic use the most stringent memory order assertion,…
jiandingzhe
  • 1,321
  • 8
  • 29
-1
votes
2 answers

Java: Splitting Code into its atomic representation

In Java, only few things are considered to be atomic (What operations in Java are considered atomic?). For example i++ consists of 3 different atomic operations: Load i into a register, add 1 to that register, write the new value of the register…
user1648409
-2
votes
1 answer

How to ensure atomicity of multiple lines of code together in Pyspark?

I am writing Pyspark code in Azure Databricks notebook where at the end of the notebook I need to write results back to 3 different places (2 tables in Database of databricks and 1 folder in ADLS ) and I have 3 different functions…
1 2 3
38
39