Previous | Next --- Slide 35 of 66
Back to Lecture Thumbnails
Iamme

Are there other implementations of atomicity without locks? Is it possible to implement atomicity in one thread without having to communicate with all the others?

neonachronism

As we saw in class, you can do small atomic operations with special instructions, and larger ones with transactional memory.

I believe in general, you only have to communicate with other threads if there is contention, but if there is, some communication is unavoidable (although it may be indirect).

ferozenaina

For small atomic instructions like increment and decrement, we wouldn't need to communicate with other threads. These special instructions ensure the read/write gets done together.

This prevent race conditions like another thread writing to it when our thread is still reading.

OpenMP also has a critical section primitive which helps having larger atomic blocks.

cuiwei

"Locks can be used to implement an atomic block", but locks only assures that no 2 thread can simultaneously enter the atomic block, and they are of no help for error recovery, right? It is ultimately programmers' responsibility to handle error recovery.