From: "Allen, Norton T." <allen@huarp.harvard.edu>
To: "René Berber" <rene.berber@gmail.com>, cygwin@cygwin.com
Subject: Re: rand is not ISO C compliant in Cygwin
Date: Sat, 11 Nov 2023 15:18:37 -0500 [thread overview]
Message-ID: <f05ddafa-2af1-4693-abd2-a862a771d963@huarp.harvard.edu> (raw)
In-Reply-To: <f8c95c12-a43e-442e-ad95-129d6340bdf4@gmail.com>
On 11/11/2023 1:25 PM, René Berber via Cygwin wrote:
> On 11/11/2023 10:50 AM, Allen, Norton T. via Cygwin wrote:
>
> [snip]
>>> The srand function is not required to avoid data races with other
>>> calls to pseudo-random sequence generation functions. ..."
>> That is not the same as "... required never to avoid data races ...".
>> "not required" means the sentence is not specifying--not
>> requiring--any behavior, so you should not depend on the described
>> behaviors.
> [snip]
>
> The elided part on Bruno's message is:
>
> "The implementation shall behave as if no library function calls the
> rand function."
>
> Which is the point Bruno is making with the sample code.
I would still assert that if the implementation is doing what I
suggested (maintaining independent state for each thread) it would still
meet that criteria, although I admit it is debatable. That said, the man
page says:
"rand and srand are unsafe for multi-threaded applications. rand_r is
thread-safe and should be used instead."
I read that as "all bets are off" if you are using them in a
multi-threaded application.
next prev parent reply other threads:[~2023-11-11 20:18 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. [this message]
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 ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
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=f05ddafa-2af1-4693-abd2-a862a771d963@huarp.harvard.edu \
--to=allen@huarp.harvard.edu \
--cc=cygwin@cygwin.com \
--cc=rene.berber@gmail.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).