Unix V4 source recovered after 50 years

Let's talk about anything related to the 6502 microprocessor.
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Unix V4 source recovered after 50 years

Post by Yuri »

Looks like some people have managed to save a real that held the source code for UNIX version 4 and read the data off of it.

The full article can be found on Tom's Hardware:
https://www.tomshardware.com/software/l ... itten-in-c

A pretty impressive and influential bit of computing history. :)
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigDumbDinosaur »

Yuri wrote:
Looks like some people have managed to save a real (sic) that held the source code for UNIX version 4 and read the data off of it.

The full article can be found on Tom's Hardware:
https://www.tomshardware.com/software/l ... itten-in-c

A pretty impressive and influential bit of computing history. :)
Yes it is.

However, this statement in the article is not quite correct:
Quote:
...Unix v4, the first version of the operating system with both its kernel and core utilities written in that shiny newfangled language known as C.
Yes, all the core utilities were written in K&R C and almost all of the kernel was as well.  However, the V4 kernel that was run on the PDP-11 had some assembly language because the machine code produced from the compiled C version simply wasn’t tight enough for a few critical functions (interrupt handlers, if my memory correctly serves me—I read about this stuff some 45 years ago).

Kernighan and Ritchie also mentioned this in their “The C Programming Language” book of 1978, on page 2 (yes, I have an original copy, purchased used at the University of Illinois bookstore in 1982), saying that about 800 lines of assembly language were part of the kernel source.  This need for assembly language in critical places persisted for a while when the first UNIX ports to PC hardware were done.  C compilers simply weren’t as efficient back then as they are now.

As for downloading and building the source, and then running it on something, that might be interesting, but not an eye-opener—UNIX’s modus operandi has remain remarkably consistent over the years (what I learned from my early encounters with UNIX in 1980 mostly applies to Linux).  The Linux user of today should not have any trouble using a 50+ year-old UNIX, but would likely be disappointed that all the bells and whistles we take for granted today aren’t there.  No BASH, no PERL, no PHP, no Python...none of that modern stuff.  :D  It would be like a life-long Porsche owner suddenly finding himself behind the wheel of a 1950 Buick Roadmaster.  :?
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigEd »

Thanks Yuri, this is big news! And it's straightforward to bring this distribution up in simh. See here
http://squoze.net/UNIX/v4/README

We've a bit of a conversation going on over here:
https://retrocomputingforum.com/t/unix- ... 5400?u=eds
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigDumbDinosaur »

BigEd wrote:
Thanks Yuri, this is big news! And it's straightforward to bring this distribution up in simh. See here
http://squoze.net/UNIX/v4/README

Interesting in reading that the procedure to get V4 UNIX running is just like what was done at my employer in 1980 when they set up a PDP-11/70 with UNIX.

The PDP had two RK05 disk units and one tape drive (can’t recall the model), and at the time, seemed to be the cutting edge of computing.  None of us at the time, as far as I knew, had any idea how far-reaching UNIX’s influence would be.  What I did quickly recognize was how much more interesting the UNIX environment was than CICS running on the company’s S370 mainframe.  CICS was as dull as a cheap kitchen knife—UNIX was cool!  :D
x86?  We ain't got no x86.  We don't NEED no stinking x86!
jgharston
Posts: 181
Joined: 22 Feb 2004

Re: Unix V4 source recovered after 50 years

Post by jgharston »

It's not so much that their C compiler wasn't efficient enough, but in crucial places you need to transition from the CPU itself doing something to getting into some C code. The PDP11 interupt handler can't jump into a C routine, it simply sets the program counter to a specified value and starts executing machine code. There needs to be machine code at that location to set the machine state into a state where it can hand on into a C routine.

And then there's things like reading user space when executing in the kernel - that has to be done in machine code as it's machine level functionality.

I downloaded the disk image and SIMH ini files, and it booted first time. I was even more impressed that my code that runs happily in UnixV5 also ran first time: link.

From testing, the only thing I've found a problem with is exec() calling /bin/sh to "shell out" to run a command. There's some difference from v5+ that I haven't worked out yet. With v5 and later you do exec("/bin/sh",("sh","-c","command line to run",0)) but on v4 that gives me: -c: cannot open. :o
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigDumbDinosaur »

jgharston wrote:
It's not so much that their C compiler wasn't efficient enough, but in crucial places you need to transition from the CPU itself doing something to getting into some C code...
As I said, I last read about it 45 years ago.  :D  A huge amount of water has gone over my cranial dam in that time.  I’m amazed I remember what I do remember about this stuff.  :shock:
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigEd »

Great screenshot JGH - very retro!
electricdawn
Posts: 34
Joined: 23 Nov 2025

Re: Unix V4 source recovered after 50 years

Post by electricdawn »

That... is ancient (the youngster would say about seeing a Windows XP screenshot). ;)

I remember my first contact with a computer was a PDP-somethingsomething (PDP-8?) in somewhat 1977/8 during my first year at the "Technische Gymnasium" in the city of Mainz/Germany. This ONE meeting kindled my lifelong interest in computers. I somehow still remember that. When my parents moved to Kaiserslautern, they sent me to the "Technische Gymnasium" (it's like a vocational high school centred around - at that time - modern technology) there, and I had access to the mini-computer (probably a PDP as well) at the university of Kaiserslautern. We had as one of the first high schools in Germany the course "Informatik" ... pretty much the theory of the basics of programming a computer. We programmed the PDP at our university - which was situated on the other side of town - with punch cards!

I bought a copy of Niklaus Wirth's "Algorithms and Data Structures" back then and it's still sitting in a shelf above my desk today!
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: Unix V4 source recovered after 50 years

Post by Yuri »

electricdawn wrote:
I remember my first contact with a computer was a PDP-somethingsomething (PDP-8?) in somewhat 1977/8 during my first year at the "Technische Gymnasium" in the city of Mainz/Germany.
My first contact with a computer was an Apple II+; I never got a chance to work with any minicomputers or mainframes. I have worked at IBM in my carrier, and the team I was on had an AS400, but despite my begging and pleading to let me learn how to use it they said no.... :cry:

I still get awe struck seeing those photos of the Cray-1, and the various big iron from the day. Even if they can't hold a candle next to today's computers, they were still pretty neat computers.
BigEd wrote:
Thanks Yuri, this is big news! And it's straightforward to bring this distribution up in simh. See here
http://squoze.net/UNIX/v4/README
I have in fact gotten it to run; simh is running very slowly (I presume to actually emulate the speed of the PDP-11 itself). Trying to see if there's an easier way to get files edited on the Windows side back into the PDP-11 so I don't have to fight with ed.
electricdawn
Posts: 34
Joined: 23 Nov 2025

Re: Unix V4 source recovered after 50 years

Post by electricdawn »

NOTHING beats the awesome images of a Cray main-frame. To me, this is still the pinnacle of "Big Iron".
barnacle
Posts: 1831
Joined: 19 Jan 2004
Location: Potsdam, DE
Contact:

Re: Unix V4 source recovered after 50 years

Post by barnacle »

Can't argue with that; the Cray was the coolest looking machine in town. The Sinclair MK14 (my first computer) wasn't a patch on it. :mrgreen:

Neil
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigDumbDinosaur »

electricdawn wrote:
NOTHING beats the awesome images of a Cray main-frame. To me, this is still the pinnacle of "Big Iron".
Yep, and to think that early versions of Cray machines were wire-wrapped and ran at the then-astonishing speed of 80 MHz.  It took some serious engineering to pull off that kind of performance.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
v4guy
Posts: 1
Joined: 31 Dec 2025

Re: Unix V4 source recovered after 50 years

Post by v4guy »

Hey, FYI if anybody wants to have a play around with this system (and admire its primitive nature) I created a website where you can get a live terminal of it in your browser: https://unixv4.dev

Check it out (and let me know if you have any feedback)
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Unix V4 source recovered after 50 years

Post by BigEd »

Marvellous - thanks for that! And thanks for automating the boot-time inputs, getting us to the # prompt.
User avatar
Yuri
Posts: 371
Joined: 28 Feb 2023
Location: Texas

Re: Unix V4 source recovered after 50 years

Post by Yuri »

v4guy wrote:
Hey, FYI if anybody wants to have a play around with this system (and admire its primitive nature) I created a website where you can get a live terminal of it in your browser: https://unixv4.dev

Check it out (and let me know if you have any feedback)
That's pretty cool. Might want to add a note to the MOTD that CTRL+C will not stop a program either..... >_>
Post Reply