This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: random number generators - rand(), random(), etc


On Fri, Nov 7, 2014 at 12:07 PM, jb <jb.1234abcd@gmail.com> wrote:
> But, if they share the *single instance* of the generator, does it not make
> both of them non-reentrant and non-threadsafe since they share a state (it
> might be e.g. a seed value) that is modified on each call by one of them ?

They are thread-safe, actually. But not reentrant. As per the man
pages. See rand_r() and random_r() for reentrant versions.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]