Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #65192

Re: thread-safe random numbers...

From "Chris M. Thomasson" <nospam@nospam.nospam>
Newsgroups comp.lang.c
Subject Re: thread-safe random numbers...
Date 2015-07-10 14:03 -0700
Organization Aioe.org NNTP Server
Message-ID <mnpc06$7k7$1@speranza.aioe.org> (permalink)
References <mk61l9$ap4$1@speranza.aioe.org> <kfnh9pb4za3.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


> "Tim Rentsch"  wrote in message 
> news:kfnh9pb4za3.fsf@x-alumni2.alumni.caltech.edu...

> > "Chris M. Thomasson" <nospam@nospam.nospam> writes:

> > I am trying to find the standard method for creating
> > random numbers in a thread-safe manner in C.  So far,
> > I can only find the `rand_r()' function.  However,
> > this seems to be a POSIX, or an "extension" to standard
> > C. In C++ it seems like I can make use of the
> > `std::default_random_engine' class . However, I need to know
> > if `rand_r()' is okay to use wrt standard C.

> Nothing available in regular C AFAIK.  The best bet might be
> putting something together yourself and using that.  I think
> the following code is not too bad - fairly good quality of
> random numbers, small memory footprint, and IIANM completely
> portable and usable in strictly conforming programs.

[...]

This looks good. Thank you for posting it Tim.

:^) 

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-27 20:22 -0700
  Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 11:11 -0700
  Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 11:19 -0700
    Re: thread-safe random numbers... Rosario19 <Ros@invalid.invalid> - 2015-05-29 07:28 +0200
  Re: thread-safe random numbers... James Kuyper <jameskuyper@verizon.net> - 2015-05-28 14:22 -0400
    Re: thread-safe random numbers... Keith Thompson <kst-u@mib.org> - 2015-05-28 12:38 -0700
      Re: thread-safe random numbers... James Kuyper <jameskuyper@verizon.net> - 2015-05-28 16:42 -0400
      Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 13:57 -0700
      Re: thread-safe random numbers... Nobody <nobody@nowhere.invalid> - 2015-05-29 22:42 +0100
  Re: thread-safe random numbers... Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 11:56 -0700
    Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 14:03 -0700
      Re: thread-safe random numbers... Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 13:44 -0700
  Re: thread-safe random numbers... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-10 12:01 -0700
    Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 13:53 -0700
      Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 13:58 -0700
      Re: thread-safe random numbers... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-10 14:04 -0700
        Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 14:23 -0700
          Re: thread-safe random numbers... Keith Thompson <kst-u@mib.org> - 2015-07-10 17:12 -0700
            Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 18:58 -0700
      Re: thread-safe random numbers... Rosario19 <Ros@invalid.invalid> - 2015-07-11 11:13 +0200

csiph-web