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.



--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to