News: 1690543512

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

OctoX is a radical Rust implementation of a very old OS for RISC-V

(2023/07/28)


Not only are various editions of Version 6 UNIX, often known as V6 for short, still being maintained – but new ones continue to appear.

Version 6 UNIX arrived in 1975, and it was the first version of the new OS to see much widespread use outside of AT&T and a handful of research institutions. It's the OS documented in the famous [1]"Lions book" [PDF], more formally known as A Commentary on the Sixth Edition Unix Operating System , and the origin of perhaps the most famous source code comment of all time: /*

* You are not expected to understand this.

*/

(If you don't know the Lions book, and want to see the source code next to the commentary, there's a more interactive web-text [2]version on GitHub.)

Perhaps surprisingly for such a primitive system from the mid-1970s, several different modern OSes derived from V6 are still around and maintained today, mainly for students learning about operating system design. So don't get too excited just yet, OctoX is not some radical new OS. It's perhaps fairer to say it's a radical new implementation of a very old OS.

It springs from [3]Xv6 , which is the Massachusetts Institute of Technology's project to modernize V6 for its Operating System Engineering course. The snag is that V6 itself was implemented for the DEC PDP-11, and in a pre-standardized version of C to boot. After a few years, the boffins at MIT decided to rewrite V6 in ANSI C for modern x86 hardware, and the result was Xv6. Its [4]source code is still available, but the x86 version has been superseded by a newer [5]version for RISC-V.

[6]

These days, despite its legions of fans, C is often deprecated as a systems programming language, at least for new systems – a view described concisely by former Google researcher Cliff Biffle's 2019 essay [7]Prefer Rust to C/C++ for new code .

[8]

[9]

A sign of its growing maturity is that people are completing significant projects in it. A recent example that impressed us is Andrea Bargi's [10]rjvm , which as the author's detailed [11]blog post explains, is a tiny, toy OpenJDK 7 Java virtual machine, written entirely in Rust.

Impressive as that is, operating systems are easier to understand and demonstrate. Another example Rust's growing suitability for ambitious projects is reimplementing Xv6 in Rust. One instance is [12]rxv64 , whose title is, in true Unix style, a very terse self-description: it's xv6, reimplemented in Rust (thus the "r" on the beginning), targeting x86-64 (the "64" on the end).

[13]

However, as its GitHub statistics illustrate, rxv64 isn't a pure Rust project:

Languages

• Rust 77.9% • C 19.3%

• Assembly 2.7% • Shell 0.1%

Enter [14]OctoX , whose stats illustrate a level of purity that excites a certain type of geek:

Languages

• Rust 100.0%

We also grinned wryly at [15]this pithy description from Hacker News:

o8vm targets RISC-V, whereas rxv64 targets a legacy ISA.

As its author Hayato Ohhashi says: "This is a learning project for me, and I will not be accepting pull requests until I consider the implementation complete." As a demonstration and a proof of concept, though, it looks very impressive, if not terribly practical – but practicality is not the goal here.

[16]Debian 12.1 released with bug fixes aplenty and excitement still in short supply

[17]Want to live dangerously? Try running Windows XP in 2023

[18]Slackware wasn't the first Linux distro, but it's the oldest still alive and kicking

[19]Mint 21.2 is desktop Linux without the faff

Unix didn't end with V6, of course, it just seems to represent a sweet spot in size and complexity of OS design for many people, especially students. In 1979, V6 was followed by V7, the first version of Unix that was designed to be portable to different machine architectures. V7 was the direct ancestor of Microsoft Xenix, and it also led to two different ports for DEC minicomputers: its PDP-11 version, V7M, later led to DEC Ultrix, and the VAX version, UNIX/32V, led to the BSD family.

When Caldera acquired the Unix source code, it [20]opened the source of versions up to and including V7. A modernized x86-32 version is [21]Robert Nordier 's v7/x86 .

For some, V7 was the classic version of Unix, and after that is when it became bloated and commercial. In academia, its descendants, which borrowed extensively from BSD, were collectively known as "Research Unix" and [22]became open source relatively recently .

The last version of Research Unix was V10. After that, the project moved on to Plan 9 from Bell Labs . That [23]continues today in the form of 9front . Since we wrote about late 2022's "the Golden Age of Ballooning", the 9front developers have released a [24]new version , "Don't Touch the Artwork". The Reg FOSS desk still feels that 9front's Plan 9 has a lot to teach the contemporary Linux and BSD world, and we recommend überhacker Drew DeVault's essay [25]In praise of Plan 9 , which came a week after our own article, for an insight into why. ®

Get our [26]Tech Resources



[1] https://cs3210.cc.gatech.edu/r/unix6.pdf

[2] https://warsus.github.io/lions-/

[3] https://pdos.csail.mit.edu/6.828/2012/xv6.html

[4] https://github.com/mit-pdos/xv6-public

[5] https://github.com/mit-pdos/xv6-riscv

[6] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2ZMPmJGaVQCMDVQoSxceToQAAA9c&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[7] http://cliffle.com/blog/prefer-rust/

[8] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZMPmJGaVQCMDVQoSxceToQAAA9c&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[9] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33ZMPmJGaVQCMDVQoSxceToQAAA9c&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[10] https://github.com/andreabergia/rjvm

[11] https://andreabergia.com/blog/2023/07/i-have-written-a-jvm-in-rust/

[12] https://github.com/dancrossnyc/rxv64

[13] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44ZMPmJGaVQCMDVQoSxceToQAAA9c&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[14] https://github.com/o8vm/octox

[15] https://news.ycombinator.com/item?id=36868728

[16] https://www.theregister.com/2023/07/25/debian_121/

[17] https://www.theregister.com/2023/07/24/dangerous_pleasures_win_xp_in_23/

[18] https://www.theregister.com/2023/07/20/slackware_turns_30/

[19] https://www.theregister.com/2023/07/19/mint_212/

[20] http://www.lemis.com/grog/UNIX/

[21] https://www.nordier.com/

[22] https://www.theregister.com/2017/03/30/old_unix_source_code_opened_for_study/

[23] https://www.theregister.com/2022/11/02/plan_9_fork_9front/

[24] http://9front.org/releases/2023/06/25/0/

[25] https://drewdevault.com/2022/11/12/In-praise-of-Plan-9.html

[26] https://whitepapers.theregister.com/



You are not expected to understand this.

Red Ted

Having looked at the section of code, my opinion is that it's not too awful.

Certainly not for task switching code whose job it is to context switch and therefore directly manipulate the underlying system state so as different code executes when you return, from the one that was running when the function was called.

Re: You are not expected to understand this.

Chris Gray 1

Agreed. Its cool, but not terrible. *Of course* the process ending call does not return. Even though its existence as a standard C call makes it look like it should if you don't actually read it.

I did similar things a couple of times for thread termination. It was a bit of a thrill to watch them work, I will admit!

When I first looked into an old Linux kernel (writing code for hardware to plug into a bus and work shared-memory-wise with the kernel), I was definitely disturbed to see that it included the same device header file(s) twice. Its been years, but I think the first time was to add the devices to the device tables(s), and the second time was to compile the actual driver code. Doing it that way meant that it was all in one file, so was less likely to get broken, but it sure broke expectations! Dunno if it still works that way.

Silly comments

Arthur the cat

From ageing memory, so not guaranteed to be 100% correct:

In version 6 the tty driver had one line (setting device register bits IIRC) commented with "Eat flaming death, fascist pigs!". In version 6+(*) this had been changed to "Eat soggy cardboard, pinko wimps!".

(*) 6+ was the update which meant that the C compiler could handle identical structure field names at different byte offsets in different structures. If you've ever wondered why all system structures have unique prefixes on all the field names (eg st_uid, st_gid in stat(2)), it was because cc originally handled field names in much the same way as BCPL, as manifest constants equal to byte offsets from the beginning of the structure.

Re: Silly comments

Steve Graham

Pertinent to Silly Comments but not v6: one of my colleagues prefaced a 60-character regular expression with the comment "Work this one out, you bastard."

The real hero of this piece

breakfast

Congratulations to Cliff Biffle on having exactly the kind of name I come up with when I'm GMing and the players ask the random shopkeeper what his name is so I have to come up with something on the spot. Big "background NPC who is about to be adopted by the party" energy.

Re: The real hero of this piece

fromxyzzy

Swear that's the name of a Bloom County character.

In "King Henry VI, Part II," Shakespeare has Dick Butcher suggest to
his fellow anti-establishment rabble-rousers, "The first thing we do, let's
kill all the lawyers." That action may be extreme but a similar sentiment
was expressed by Thomas K. Connellan, president of The Management Group, Inc.
Speaking to business executives in Chicago and quoted in Automotive News,
Connellan attributed a measure of America's falling productivity to an excess
of attorneys and accountants, and a dearth of production experts. Lawyers
and accountants "do not make the economic pie any bigger; they only figure
out how the pie gets divided. Neither profession provides any added value
to product."
According to Connellan, the highly productive Japanese society has
10 lawyers and 30 accountants per 100,000 population. The U.S. has 200
lawyers and 700 accountants. This suggests that "the U.S. proportion of
pie-bakers and pie-dividers is way out of whack." Could Dick Butcher have
been an efficiency expert?
-- Motor Trend, May 1983