Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does __sync_synchronize do?

Tags:

c++

c

linux

I saw an answer to a question regarding timing which used __sync_synchronize().

  • What does this function do?
  • And when is it necessary to be used?
like image 866
Superpolock Avatar asked Jun 11 '09 16:06

Superpolock


2 Answers

It is a atomic builtin for full memory barrier.

No memory operand will be moved across the operation, either forward or backward. Further, instructions will be issued as necessary to prevent the processor from speculating loads across the operation and from queuing stores after the operation.

Check details on the link above.

like image 61
nik Avatar answered Sep 19 '22 01:09

nik


It forces a memory fence I guess.

like image 20
Nikolai Fetissov Avatar answered Sep 21 '22 01:09

Nikolai Fetissov