Memory barrier for fat initialization

Torbjörn Granlund tg at gmplib.org
Tue Jan 13 13:58:28 UTC 2015


nisse at lysator.liu.se (Niels Möller) writes:

  GMP's fat initialization (I'm looking at the x86_64 code now) ends with
  
    *((volatile int *) &__gmpn_cpuvec_initialized) = 1;
  
  I suspect that it's possible (but unlikely) that a different thread on
  another cpu may read __gmpn_cpuvec_initialized, get 1, read thresholds
  or pointers, and still get old values.

How could that happen?  Please elaborate.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list