Atomic action - mutex

I heard that there is something known as an "atomic action" that is faster than using a mutex with a critical sector. Does anyone know what it is and how to use it?

+3
source share
5 answers

An atomic operation is an operation in which the processor reads and writes memory during the same access to the bus, which prevents the simultaneous change of other processors or system devices. For instance. operation "test and installation", which can "read memory at location X", if it is set to 1, return an indicator indicating whether the value "without simultaneous access" has been set.

Wikipedia http://en.wikipedia.org/wiki/Linearizability .

, , . InterlockedTestExchange InterlockedIncrement, .

:

- :

while (test_and_set(&x) == 1) ;

, , x 1. x , , .

+6

. , " ". , .

, . , - CPU. , - FIFO. .

, , , .

+1

(shurely in windows) (cs), , . , , , - . , , / , .

(google " " " " )

This is interesting, but very complex material and is not recommended if some simple solution also works (for example, a critical section).

0
source

Source: https://habr.com/ru/post/1795442/


All Articles