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


Groups > comp.lang.c > #62736

Re: thread-safe random numbers...

From "Chris M. Thomasson" <nospam@nospam.nospam>
Newsgroups comp.lang.c
Subject Re: thread-safe random numbers...
Date 2015-05-28 11:11 -0700
Organization Aioe.org NNTP Server
Message-ID <mk7lpl$638$1@speranza.aioe.org> (permalink)
References <mk61l9$ap4$1@speranza.aioe.org>

Show all headers | View raw


> "Chris M. Thomasson"  wrote in message 
> news:mk61l9$ap4$1@speranza.aioe.org...

> 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.

Well, according to:

http://www.cplusplus.com/reference/cstdlib/rand

It appears that if I want thread-safe random numbers in C, I
have to roll my own, or use the non-portable function `rand_r()'.

Damn!

I hope I am simply missing something important here.

IMVHO, this seems to be a flaw, especially since threading is
now a standard aspect of C...

;^o 

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