The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Rob Pike <robpike@gmail.com>
To: ron minnich <rminnich@gmail.com>
Cc: Jonathan Gray <jsg@jsg.id.au>, Russ Cox <rsc@swtch.com>, tuhs@tuhs.org
Subject: [TUHS] Re: early unix rand
Date: Thu, 14 Mar 2024 07:25:25 +1100	[thread overview]
Message-ID: <CAKzdPgx3z56sCCA4RR8TeR5OzvdjfKxziv2kHQb5hQ9Y3ACC-w@mail.gmail.com> (raw)
In-Reply-To: <CAP6exYKuM+rYCpT1NWJm6wPBLBS_aRNds51ek5SfVV8coYH+8w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4405 bytes --]

Norm Schryer wrote a (nearly?) exhaustive floating-point tester that he ran
when a new CPU arrived, always with wrong results. Doug McIlroy probably
knows more about it than I do, who only observed it from afar.

-rob


On Thu, Mar 14, 2024 at 4:18 AM ron minnich <rminnich@gmail.com> wrote:

> Got the name wrong: Computer Engineering: A DEC View of Hardware Systems
> Design
>
> On Wed, Mar 13, 2024 at 9:41 AM ron minnich <rminnich@gmail.com> wrote:
>
>> by the way, I realize that random number urban legend sounds ridiculous,
>> in light of how hardware design is done today, but those of you who did
>> hardware design in those days (guilty!), and had access to -11
>> schematics and boards, might wonder if it's not possible. There was a
>> habit, in those days,  for performance reasons, of subbing transparent
>> latches for flip-flops to gain a little time. An engineer I knew at Amdahl
>> said that was a pretty hot topic there. Certainly, the technique of design
>> for testability was not really in wide use in the -11 days. Gordon Bell's
>> book "Computer Design" is particularly instructive.
>>
>> E.g., how did you verify the floating point on your new machine? Put an
>> older machine next to a new machine, do lots of computation, see if there
>> is disagreement, you've found a bug in the new machine, right? Maybe.
>> Sometimes,  you discover the older machine had a bug the newer one did not
>> ... happened more than once, including on the 360 to 370 transition.
>>
>> On Tue, Mar 12, 2024 at 6:09 PM ron minnich <rminnich@gmail.com> wrote:
>>
>>> There used to be an urban legend about multiply overflow and the PDP 11.
>>>
>>> This would’ve been circa 1976. Someone from DEC told us that on a
>>> multiply overflow, the contents of the destination register would be “kind
>>> of” random. I was never able to verify that claim. But that might explain
>>> this code.
>>>
>>> On Tue, Mar 12, 2024 at 16:05 Jonathan Gray <jsg@jsg.id.au> wrote:
>>>
>>>> On Tue, Mar 12, 2024 at 08:55:02AM -0400, Russ Cox wrote:
>>>> > Hi all (and TUHS),
>>>> >
>>>> > The Third Edition rand(III) page [1] ends with
>>>> >
>>>> > WARNING  The author of this routine has been writing
>>>> >     random-number generators for many years and has
>>>> >     never been known to write one that worked.
>>>> >
>>>> > My understanding is that Ken wrote the rand implementation.
>>>> > But I'm curious about the origin of this warning.
>>>> > I had assumed that Ken wrote it as a combination warning+joke,
>>>> > but Rob suggested that to him it didn't sound like Ken and
>>>> > perhaps Doug or Dennis had written it. Does anyone remember?
>>>> >
>>>> > Separately, I am trying to find out what the very first
>>>> > Unix rand implementation was. In the TUHS archives,
>>>> > the incomplete V2 sources contain a reference to srand
>>>> > in cmd/bas0.s [2], but there is no definition in the tree.
>>>> > The V3 man pages list it, but as far as I can tell full
>>>> > library sources do not appear in the TUHS archives
>>>> > until the V6 snapshot. The V6 rand [3] is:
>>>> >
>>>> > rand:
>>>> >     mov r1,-(sp)
>>>> >     mov ranx,r1
>>>> >     mpy $13077.,r1
>>>> >     add $6925.,r1
>>>> >     mov r1,r0
>>>> >     mov r0,ranx
>>>> >     bic $100000,r0
>>>> >     mov (sp)+,r1
>>>> >     rts pc
>>>>
>>>> matches V5:
>>>> https://www.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s3/rand.s
>>>> Distributions/Research/Dennis_v5/v5root.tar.gz
>>>> <https://www.tuhs.org/cgi-bin/utree.pl?file=V5/usr/source/s3/rand.sDistributions/Research/Dennis_v5/v5root.tar.gz>
>>>>
>>>> >
>>>> > Perhaps this is the original rand as well? It is hard to imagine
>>>> > a much simpler one, other than perhaps removing the addition,
>>>> > but doing so would create a sequence of only odd numbers.
>>>> > >From the man page description it sounds like this has to be the
>>>> > original generator, perhaps with different constants.
>>>> >
>>>> > Thanks!
>>>> >
>>>> > Best,
>>>> > Russ
>>>> >
>>>> > [1]
>>>> >
>>>> https://github.com/dspinellis/unix-history-repo/blob/Research-V3/man/man3/rand.3
>>>> > [2]
>>>> >
>>>> https://github.com/dspinellis/unix-history-repo/blob/Research-V2/cmd/bas0.s
>>>> > [3]
>>>> >
>>>> https://github.com/dspinellis/unix-history-repo/blob/Research-V6/usr/source/s3/rand.s
>>>>
>>>

[-- Attachment #2: Type: text/html, Size: 6373 bytes --]

  reply	other threads:[~2024-03-13 20:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 12:55 [TUHS] " Russ Cox
2024-03-12 18:08 ` [TUHS] " Russ Cox
2024-03-12 23:05 ` Jonathan Gray
2024-03-13  1:09   ` ron minnich
2024-03-13 16:41     ` ron minnich
2024-03-13 17:17       ` ron minnich
2024-03-13 20:25         ` Rob Pike [this message]
2024-03-13 20:34           ` Clem Cole
2024-03-14 19:24             ` Dave Horsfall
2024-03-12 14:37 [TUHS] " Douglas McIlroy
2024-03-12 16:23 ` [TUHS] " Paul Winalski
2024-03-13  1:22   ` Russ Cox
2024-03-12 16:32 ` Ken Thompson

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=CAKzdPgx3z56sCCA4RR8TeR5OzvdjfKxziv2kHQb5hQ9Y3ACC-w@mail.gmail.com \
    --to=robpike@gmail.com \
    --cc=jsg@jsg.id.au \
    --cc=rminnich@gmail.com \
    --cc=rsc@swtch.com \
    --cc=tuhs@tuhs.org \
    /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 NNTP newsgroup(s).