public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "newlib@sourceware.org" <newlib@sourceware.org>
Cc: Corinna Vinschen <vinschen@redhat.com>,
	"cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: [EXTERNAL] Re: rand is not ISO C compliant in Cygwin
Date: Mon, 13 Nov 2023 16:44:08 +0000	[thread overview]
Message-ID: <DM8PR09MB7095FD4287584FC53200831CA5B3A@DM8PR09MB7095.namprd09.prod.outlook.com> (raw)
In-Reply-To: <ZVJM7g9smHGMN7QH@calimero.vinschen.de>

IMHO:

>   2. A different sequence

The word "different" in this context is ambiguous: is it "unrelated" as a generator, or is it "not the same" sequence of the actual numbers?

> I read this as the newlib technique being one way of correctly implementing rand/srand, no?

If the first, then yes; but if the second, then no.

The problem with the first approach is, however, is the inability to adequately randomize your code (e.g. for testing).

You call srand() in the main() thread, and then spawn threads thinking they will inherit the randomization; but in fact, they all start off the same number sequence, regardless.

Anton Lavrentiev
Contractor NIH/NLM/NCBI


  reply	other threads:[~2023-11-13 16:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-10 20:19 Bruno Haible
2023-11-10 21:39 ` Norton Allen
2023-11-10 22:27   ` Bruno Haible
2023-11-11 16:50     ` Allen, Norton T.
2023-11-11 18:25       ` René Berber
2023-11-11 20:18         ` Allen, Norton T.
2023-11-13 14:17 ` Corinna Vinschen
2023-11-13 14:25   ` Bruno Haible
2023-11-13 14:38     ` Corinna Vinschen
2023-11-13 16:21       ` Corinna Vinschen
2023-11-13 16:44         ` Lavrentiev, Anton (NIH/NLM/NCBI) [C] [this message]
2023-11-13 21:33         ` Bruno Haible
2023-11-13 22:14           ` Glenn Strauss
2023-11-14 10:20             ` Corinna Vinschen
2023-11-14 10:11           ` Corinna Vinschen
2023-11-14 11:52             ` Bruno Haible
2023-11-14 16:59               ` Corinna Vinschen
2023-11-14 18:06                 ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM8PR09MB7095FD4287584FC53200831CA5B3A@DM8PR09MB7095.namprd09.prod.outlook.com \
    --to=lavr@ncbi.nlm.nih.gov \
    --cc=cygwin@cygwin.com \
    --cc=newlib@sourceware.org \
    --cc=vinschen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).