From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [IPv6:2600:3c01:e000:146::1]) by inbox.vuxu.org (Postfix) with ESMTP id 70963263C7 for ; Tue, 12 Mar 2024 13:55:34 +0100 (CET) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 8ECA442885; Tue, 12 Mar 2024 22:55:25 +1000 (AEST) Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by minnie.tuhs.org (Postfix) with ESMTPS id B1A3A42883 for ; Tue, 12 Mar 2024 22:55:14 +1000 (AEST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dc13fb0133so28402625ad.3 for ; Tue, 12 Mar 2024 05:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swtch.com; s=google; t=1710248114; x=1710852914; darn=tuhs.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=39E5SK8PpkHAWpk//jRKS0E/f8C3MWaMebLwDEUU4yM=; b=SDoVy1AB8EJBmm7OYmADfPOL/CowYPh/SMVtrWfCgEuofaVcVHBZRlweXeF9iOlD6y gtODpBO21mzNidIbIadwMsSQk/oKn8mpbYCpPF/RwkyKBhhAuSZVziNG/liKUhsKtSxR p/cGlTj8XJA2LzbX2rVgt/n1F57SBnYJ1ccumIQ/4NjgQ+7JhjYv5Q4BH7ACqbT98yjZ FBSE8zNWm96sXa49N9sMU1yaml8qS1h+9KbvZmnKbZ17/3jaHZUnPNaGzqGGXGng50Na 1y7PtKvuMjrLXvTIJDOpzHeI8xYaBNn+V7dzjNnzmPeWNnA1iDwlx9JEA9wDZ1DbJ/oP BSRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710248114; x=1710852914; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=39E5SK8PpkHAWpk//jRKS0E/f8C3MWaMebLwDEUU4yM=; b=s1heDX9RHeD7hpM6fPy3tJvISL4/nABwXbNwAooe9AYVASKA/gZ22Plks6pPBTS/B3 z+11WfJDHdmlWfSp9Pe8Trp1H88e2owNF1drElVvid8eNlVAM1UrPn1pbFaFvv4mH46Q m5Kd2tOXElL9P9jUFbghnZszOVQRbUxTRLA681w8BMIF9ps/lQzlW6U0fM3G9On8KAC+ YsvYFHMiGaYLd0ZBFRef6hlrNzqfm2M0aviG1GK1ltwv4BYz6KkqFdJh5gjErW8w2sH/ 59IufH+VC/MiO3OHTkawv0pwz7s1YDOk6Gwj1EQlef2kLprg8Qp2kVhmdTxakNPM14zS CMuw== X-Gm-Message-State: AOJu0YwqmWZviwRtbxev1L2CudjuWyg0+4pnEK46ZbgOB6gY+lYLAqQF yYg4bmLepcuLWEDHgbLAyBqV3ThNo2QWnlooaxNg3jdmHgCKISNdhRldL42a/PupKnWFrynBcfX AYX+scFrBQ+DquL2jix51hWjeIl/UPTCWwgUa X-Google-Smtp-Source: AGHT+IFEGHG7jPZGUVZaHvzyHmSGm27GW6O52XyII3ar8x5QCb7GumWfEf+ENwyagXw+VxxJtyrdDyssDFdkV8GBtb0= X-Received: by 2002:a17:902:ab8c:b0:1dd:75c6:faa7 with SMTP id f12-20020a170902ab8c00b001dd75c6faa7mr7760518plr.36.1710248113942; Tue, 12 Mar 2024 05:55:13 -0700 (PDT) MIME-Version: 1.0 From: Russ Cox Date: Tue, 12 Mar 2024 08:55:02 -0400 Message-ID: To: Ken Thompson , Douglas McIlroy , "Rob 'Commander' Pike" Content-Type: multipart/alternative; boundary="0000000000004f635c0613762bc5" Message-ID-Hash: VZMY7TMTDTWAMNX7S53CTLT35RSXMYAC X-Message-ID-Hash: VZMY7TMTDTWAMNX7S53CTLT35RSXMYAC X-MailFrom: rsc@swtch.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: tuhs@tuhs.org X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] early unix rand List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --0000000000004f635c0613762bc5 Content-Type: text/plain; charset="UTF-8" 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 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 --0000000000004f635c0613762bc5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all (and TUHS),

The Third Edition ra= nd(III) page [1] ends with

WARNING=C2=A0 The author of this r= outine has been writing=C2=A0
=C2=A0 =C2=A0 random-number generat= ors for many years and has=C2=A0
=C2=A0 =C2=A0 never been known t= o write one that worked.

My understanding is that = Ken wrote the rand implementation.
But I'm curious about the = origin of this warning.=C2=A0
I had assumed that Ken wrote it as a combi= nation warning+joke,
but Rob suggested that to him it didn't = sound like Ken and
perhaps Doug or Dennis had written it. Does an= yone remember?

Separately, I am trying to find out= what the very first
Unix rand implementation was. In the TUHS ar= chives,
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=C2=A0
l= ibrary sources do not appear in the TUHS archives
until the V6 sn= apshot. The V6 rand [3] is:

rand:
=C2=A0 = =C2=A0=C2=A0mov r1,-(sp)
=C2=A0 =C2=A0=C2=A0mov ranx,r1
=C2=A0 =C2=A0= =C2=A0mpy $13077.,r1
=C2=A0 =C2=A0=C2=A0add $6925.,r1
=C2=A0 =C2=A0= =C2=A0mov r1,r0
=C2=A0 =C2=A0=C2=A0mov r0,ranx
=C2=A0 =C2=A0=C2=A0bic= $100000,r0
=C2=A0 =C2=A0=C2=A0mov (sp)+,r1
=C2=A0 =C2=A0 rts pc
<= /div>

Perhaps this is the original rand as well? It is h= ard to imagine
a much simpler one, other than perhaps removing th= e addition,
but doing so would create a sequence of only odd numb= ers.
From the man page description it sounds like this has to be = the
original generator, perhaps with different constants.

Thanks!

Best,
Russ

=



--0000000000004f635c0613762bc5--