top | item 36865682

Octox: Unix-like OS in Rust inspired by xv6-riscv

190 points| o8vm | 2 years ago |github.com

119 comments

order

bakul|2 years ago

How does this compare with https://github.com/dancrossnyc/rxv64 ? From its README.md:

rxv64 is a pedagogical operating system written in Rust that targets multiprocessor x86_64 machines. It is a reimplementation of the xv6 operating system from MIT.

o8vm|2 years ago

octox is also different in that the kernel, userland, mkfs, and build system are all implemented in Rust, and I think it is also different at the type level, for example, octox using mpmc for Pipe, and using OnceLock and LazyLock for static variable initialization.

snvzz|2 years ago

I immediately notice that o8vm targets RISC-V, whereas rxv64 targets a legacy ISA.

Santosh83|2 years ago

Why does it seem like 80 to 90% of hobby OS projects that are started are "Unix-like?" Don't we already have a huge variety of Unix-like OSes out there? Why not explore new models?

linguae|2 years ago

Through various market forces, Unix (and its descendants/clones) and Windows killed most of the rest of the OS ecosystem over 20 years ago. There are generations of software engineers and computer scientists who’ve never studied operating systems that weren’t Unix- or Windows-based. Most leading OS textbooks (Tanenbaum’s books, the dinosaur book, Three Easy Pieces) have a Unix slant. Even the systems software research community is heavily Unix-centric; I say that as someone who used to be immersed in the research storage systems community. The only non-Unix or Windows operating systems many practitioners and even researchers may have used in their lives are MS-DOS and the classic Mac OS, and there’s a growing number of people who weren’t even born yet by the time these systems fell out of common use.

However, the history of computing contains examples of other operating systems that didn’t survive the marketplace but have interesting lessons that can apply to improving today’s operating systems. The Unix Hater’s Handbook is a nice example of alternative worlds of computing that were still alive in the 1980s and early 1990s. VMS, IBM mainframe systems, Smalltalk, Symbolics Genera, Xerox Mesa and Cedar, Xerox Interlisp-D, and the Apple Newton were all real-world systems that demonstrate alternatives to the Unix and Windows ways of thinking. Project Oberon is an entire system developed by Wirth (of Pascal fame) whose design goal is to build a complete OS and development environment that is small enough to be understood for pedagogical purposes, similar to MINIX but without any Unix compatibility. Reading the history of failed Apple projects such as the planned Lisp OS for the Newton and the ill-fated Pink/Taligent project are also instructive. Microsoft Research did a lot of interesting research in the 2000s on operating systems implemented in memory-safe languages, notably Singularity and Midori.

From learning about these past projects, we can then imagine future directions for OS design.

sneed_chucker|2 years ago

Because we effectively live in a Unix monoculture world, in terms of operating systems that you can actually use and study the inner workings of.

It was a legal anomaly that resulted in early Unix (aka Research Unix) being distributed with its source code for free to universities, which was enough to get the ball rolling on stuff like BSD and Lion's annotated V6 source code, that by the time AT&T decided that closed source commercial Unix was the game it wanted to play, the cat was already out of the bag.

By the time the free software and open source movements had gained some ground, enough people had studied or worked on some kind of Unix kernel and Userland source code that projects like Linux, Minix, and Free/Net/Open BSD were feasible. The fact that Linux running on x86 subsequently ate the world was probably something few people saw coming.

The other lineages of operating systems, e.g. Windows NT, OpenVMS, IBM's various offerings, either never have their source released or only have their source released long after they're obsolete.

nextaccountic|2 years ago

What is an OS good for if not to run programs? You either port existing programs to your API (lots of work) or design the OS with an existing API in mind. Or forget about existing programs and write entirely new programs

"Unix-like" describes the second approach, you provide a POSIX API but can have different internals

Now, maybe you wanted to have two APIs: one native API for the apps you write, and a translator from another, more popular API to your native API. Sounds like a lot of work when almost all software that will ever run on your OS will the translator

packetlost|2 years ago

We need more Plan 9-likes!

But more seriously, the Unix/POSIX-like OS is a pretty good model, but IMO we could do better, especially in the microkernel front.

im_down_w_otp|2 years ago

We created a funky little OS on top of seL4 & Rust that's most certainly not Unix-like, and is more akin to an RTOS-like approach to building & bundling software. More for purpose-built appliances than a general purpose OS.

inkyoto|2 years ago

Because of the availability of the source code under a permissive licence that UNIX has been distributed under for a long time. Other operating systems source code still remains unavailable, sometimes decades after the hardware they used to run on had disappeared.

The second reason is the simplicity of abstractions and the ease of their implementation. In the original DEC documentation on RSX-11M (the predecessor of VAX VMS), for example, there is a whole chapter describing how to create and fill in a file descriptor block (a complex record data structure) required just to open a file where the user has to decide beforehand where to locate the file, whether they want to access the data [blocks] randomly or sequentially, whether the file is being opened merely for updating the data but not extending the file size or for updating the data and extending the file, whether allow or not other processes to access the same file whilst it is open, the number of in-memory buffers for the kernel to allocate for file access etc etc. Many complex decisions have to be made before a file can be opened. In UNIX, on the other hand, it is a mere «int fd = open ("myfile", O_RDONLY);», the end.

Granted, not every OS has had such complexities (the opposite is also true, tho). Yet, the simplified (one can argue that it has been oversimplified) UNIX abstractions have been influential for a reason.

bsder|2 years ago

Because the only large, available, free ecosystem of software (both applications and hardware drivers) is completely built around the Unix abstractions.

If you don't want to do Unix, you have to reduplicate ALL of it. And that's like trying to boil the ocean.

OJFord|2 years ago

Is it perhaps interoperability?

If you're not that serious about it, it's a way to get a bit more for free?

Contrast Redux, which is quite a serious (not in the 'we compete with Windows' sense, but still) project I gather, which... I don't know how they describe it, but it's sort of Unix-ish, Unix-rethought? I've never actually played with it, but loved the idea of 'everything is a url' (not file) when I heard it described & explained on The Bike Shed podcast I think.

smasher164|2 years ago

It’s hard enough to learn osdev. If you have a concrete design to fall back on, you can focus on implementation.

Coming up with an original design for OSes is like a 3rd project thing.

crickey|2 years ago

What is even Unix-like ? I usually associate it with POSIX but maybe thats naive

zvmaz|2 years ago

There's XINU (Xinu's Not Unix). There's a book that walks you through the complete implementation of the OS in C [1].

[1] https://xinu.cs.purdue.edu/

lmm|2 years ago

Unix is a lot more amenable than most older OSes to being implemented by a disparate group of people with limited communication, hence why GNU was originally set up as a reimplementation of unix.

chaxor|2 years ago

I think the main selling point for Unix-like OS, but in Rust, is focused on Rust. It's to ensure that the memory related errors are less likely, and hopefully with enough work, the system can be essentially what we have today, but with less CVEs.

It's honestly a decent goal and I'm in support of it.

I know that there will inevitably be many now that come to state the obvious "well it doesn't guarantee safety" and "there are other reasons for CVE", etc. Nonetheless, it's not a bad idea.

kjs3|2 years ago

Why does it seem like 80 to 90% of hobby OS projects that are announced here as "Unix-like" invariably get someone who replies with "that thing you're doing as a hobby, for fun...you're doing it wrong and I don't approve". Zero content, zero insight posts about someones else's toy aren't useful. You want a 'new model', start coding.

guerrilla|2 years ago

If it ain't broke, don't fix it.

All kinds of new OS ideas can be implemented on UNIX like Mach[1], FLASK[2] and 9P[3] while internally a UNIX-like system doesn't need to be anything like a UNIX[4]... So who cares? What are you worried about losing? What can't be implemented on a UNIX-like system?

1. see MacOS

2. see SELinux

3. see v9fs

4. see Windows and BeOS which both have POSIX APIs

jacquesm|2 years ago

Because if you manage to get to some level of POSIX compatibility you can leverage that into having a whole toolchain and lots of other goodies up and running in a relatively short time. This limits the amount of effort required to get to 'first base', a self hosting environment.

pjmlp|2 years ago

Because it is less effort to copy already existing stacks, than be creative in trailing not yet discovered paths.

hulitu|2 years ago

It is only marketing. It does not seem to implement anything from POSIX or SUS.

Brian_K_White|2 years ago

At both extreme opposite ends of the scale/funding/people spectrum we already have TempleOS and Fuscia, and probably countless in between. You tell me why they aren't going anywhere even though any properties you might say about one, the other has the opposite quality and is also going nowhere.

Maybe "unix-like" is really just a principle that has no expiration date, like "murder is wrong".

Depending on how slavishly you define "unix-like", for instance, I would not say that the principle philosophy dictates there shall always be a command named "rm" that takes these options and does this task a la posix specs.

But for today and certainly any forseeable time, it's perfectly useful to "merely" reimplement posix.

jijji|2 years ago

its better than being OS400-like, isnt it?

stevefan1999|2 years ago

Oh you have did what I did in the shadow...I wonder if I later GPL'd it the license won't be compatible to take the code in...But I runs in x86_64 with custom QEMU UEFI loader anyway

yasuoyamasaki|2 years ago

Just one hacker developed this OS, ya know!

mysterydip|2 years ago

What does "written in safe Rust as much as possible" mean? Are there functions with no equivalent in rust?

OtomotO|2 years ago

Interfacing with hardware means you have to drop to "unsafe" rust at some (few) points.

"Unsafe" rust isn't named good, because it's still safer than e.g. C.

Some invariants you cannot break in rust, no matter if "safe" or "unsafe"

cnuts|2 years ago

That's really cool, great job!

freecodyx|2 years ago

Not related to the project. Most of the code is unsafe. I really find rust counterintuitive.

This is just a note to myself. * rust uses llvm as a backend * rust tries to solve the memory issues commonly found in C bu enforcing a programming paradigm which allow the compiler to detect them at compile time. * it tries to provide 0 cost abstractions

It works but the code is ugly

segfaltnh|2 years ago

Wait, most of _what_ code is unsafe? Aside from this one comment it sounds like you just came here to shit on Rust, lol.