Random Generate & Thread Safety
Derek Clegg
dclegg at apple.com
Fri Nov 18 00:50:50 CET 2011
On Nov 17, 2011, at 12:11 PM, Torbjorn Granlund wrote:
> "james at jamesbb.co.uk" <james at jamesbb.co.uk> writes:
>
> To achieve thread-safety, is it sufficient to keep the gmp_randstate_t structure in thread-local storage?
>
> No. Just like for *any* variable in GMP or elsewhere, gmp_randstate_t cannot safely be written by two threads, or read by one thread and written by another, without exclusion mechanisms. There is nothing magic about gmp_randstate_t that would make it different.
If it's in thread-local storage, how can it be written by two threads, or read by one thread and written by another?
Derek
More information about the gmp-discuss
mailing list