Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2001 14:59:43 -0800 (PST)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        "Andrey A. Chernov" <ache@nagual.pp.ru>, "Jacques A. Vidrine" <n@nectar.com>, arch@FreeBSD.ORG
Subject:   Re: rand.c patch for review (was: Re: cvs commit: ports/astro/xglobe/files patch-random)
Message-ID:  <200102262259.f1QMxhP46130@earth.backplane.com>
References:  <20010225132152.A39554@mollari.cthul.hu> <20010226005004.B59772@nagual.pp.ru> <20010225135429.A47615@mollari.cthul.hu> <20010226020827.A61007@nagual.pp.ru> <20010225151519.A63582@mollari.cthul.hu> <20010226022902.A61216@nagual.pp.ru> <20010225173445.A37510@spawn.nectar.com> <20010226024456.A61566@nagual.pp.ru> <20010226174852.B435@ringworld.oblivion.bg> <20010226191008.A72434@nagual.pp.ru> <20010226142211.A20768@mollari.cthul.hu>

next in thread | previous in thread | raw e-mail | index | archive | help

:> random() (which is NOT original code). Practice says that nobody seriously
:> want old behaviour. Moreover, standards (like SUSv2 f.e.) don't guarantee
:> that the formula must be the same on different machines or even through
:> different libc versions. It must be the same for single application run
:> only, so in theory we can change formula for each application run :-)
:>=20
:> So, I plan to skip this step as superfuous.

    You can't change the formula for each application run.  One of the
    biggest reasons one specifies a seed is to ensure that the same
    random sequence will be produced across multiple program runs.
    Otherwise debugging can very difficult to impossible.  Calling
    srandomdev() for random/srandom is a sufficient statement of intent
    to not want a reproducable sequence.  calling srandom() is a sufficient
    statement of intent that you want a reproducable sequence.  For 
    rand() you don't have a choice.  You only have srand() to call (and
    get a fixed seed of 1 if you don't).  The specs imply that if you will
    get the same random sequence given the same seed.  While we can change
    the algorithm between releases without creating too much dissention,
    we sure as hell can't change the algorithm for every process.

    The way I see it, we can only protect programmers against their own
    stupidity to a certain degree.  We should not be wasting resources
    trying to make rand() perfect.  It just needs to be able to do its
    jobs fairly well within the bounds of the API.

						-Matt


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102262259.f1QMxhP46130>