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.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [50.116.15.146]) by inbox.vuxu.org (Postfix) with ESMTP id 98B9B20DFF for ; Wed, 13 Mar 2024 00:05:40 +0100 (CET) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id AF0AE42876; Wed, 13 Mar 2024 09:05:33 +1000 (AEST) Received: from lechuck.jsg.id.au (jsg.id.au [193.114.144.202]) by minnie.tuhs.org (Postfix) with ESMTPS id A1E1642871 for ; Wed, 13 Mar 2024 09:05:23 +1000 (AEST) Received: from largo.jsg.id.au (largo.jsg.id.au [192.168.1.43]) by lechuck.jsg.id.au (OpenSMTPD) with ESMTPS id fc3994f4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 13 Mar 2024 10:05:20 +1100 (AEDT) Received: from localhost (largo.jsg.id.au [local]) by largo.jsg.id.au (OpenSMTPD) with ESMTPA id 2027e9dc; Wed, 13 Mar 2024 10:05:20 +1100 (AEDT) Date: Wed, 13 Mar 2024 10:05:20 +1100 From: Jonathan Gray To: Russ Cox Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Message-ID-Hash: AOURNCB3SZJLX5BXC6KTMH5EJ57CY66C X-Message-ID-Hash: AOURNCB3SZJLX5BXC6KTMH5EJ57CY66C X-MailFrom: jsg@jsg.id.au 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] Re: 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: 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 > > 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