All Questions

1663
votes
25answers
434126 views

What's the difference between the atomic and nonatomic attributes?

What do atomic and nonatomic mean in property declarations? @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *userNam...
128
votes
13answers
9228 views

Can num++ be atomic for 'int num'?

In general, for int num, num++ (or ++num), as a read-modify-write operation, is not atomic. But I often see compilers, for example GCC, generate the following code for it (try here): Since line 5, ...
15
votes
5answers
1670 views

Why is integer assignment on a naturally aligned variable atomic on x86?

I've been reading this article about atomic operations, and it mentions 32bit integer assignment being atomic on x86, as long as the variable is naturally aligned. Why does natural alignment assure a...
200
votes
6answers
96204 views

What is the difference between atomic / volatile / synchronized?

How do atomic / volatile / synchronized work internally? What is the difference between the following code blocks? Code 1 private int counter; public int getNextUniqueIndex() { return counter+...
167
votes
10answers
134351 views

Practical uses for AtomicInteger

I sort of understand that AtomicInteger and other Atomic variables allow concurrent accesses. In what cases is this class typically used though?
5
votes
4answers
12080 views

What is atomicity in dbms

I read something like below in 1NF form of DBMS. There was a sentence as follows: "Every column should be atomic." Can anyone please explain it to me thoroughly with an example?
47
votes
5answers
13215 views

Atomic UPSERT in SQL Server 2005

What is the correct pattern for doing an atomic "UPSERT" (UPDATE where exists, INSERT otherwise) in SQL Server 2005? I see a lot of code on SO (e.g. see Check if a row exists, otherwise insert) with ...
39
votes
3answers
18610 views

What operations are atomic in C#?

Is there a systematic way to know whether an operation in C# will be atomic or not? Or are there any general guidelines or rules of thumb?
68
votes
10answers
34711 views

Django: How can I protect against concurrent modification of database entries

If there a way to protect against concurrent modifications of the same data base entry by two or more users? It would be acceptable to show an error message to the user performing the second commit/s...
26
votes
6answers
5752 views

SSE instructions: which CPUs can do atomic 16B memory operations?

Consider a single memory access (a single read or a single write, not read+write) SSE instruction on an x86 CPU. The instruction is accessing 16 bytes (128 bits) of memory and the accessed memory loca...

Previous Next