Show HN: Anos – a hand-written ~100KiB microkernel for x86-64 and RISC-V

github.com

113 points by noone_youknow 5 days ago

I pretty much always have a kernel project going on, and have been that way for decades. Over the past couple of years, that's been Anos, which has gotten further along than any of my previous hobby kernels, supporting IPC, multitasking, SMP (x86-64 only right now) and running on real hardware.

LLMs (mostly Claude Code) have been used during development, but I learned early on that it's not _great_ at code at this level, so I've restricted its use to mostly documentation and tests. There's _a little_ AI code in the user space, but I have a strict "no AI code" rule in the kernel itself. I find this helps not only with the quality / functionality of the code, but also with learning - for example, even though I've written multiple kernels in the past, it wasn't until Anos that I _truly_ grokked pagetable management and what was possible with a good VMM interface, and if I'd outsourced that implementation to an LLM I probably wouldn't have learned any of that.

In terms of approach, Anos avoids legacy platform features and outdated wiki / tutorial resources, and instead tries to implement as much as possible from manuals and datasheets, and it's definitely worked out well so far. There's no support for legacy platform features or peripherals, with all IO being memory mapped and MSI/MSI-X interrupts (no PIC), for example, which has helped keep the codebase focused and easy to work on. The kernel compiles to about 100KiB on x86-64, with enough features to be able to support multitasking and device drivers in user space.

As a hobby project, progress ebbs and flows with pressures of my day job etc, and the main branch has been quiet for the last few months. I have however been working on a USB stack as time allows, and hopefully will soon have at least basic HID support to allow me to take the next step and make Anos interactive.

I don't know how useful projects like Anos are any more, given we now live in the age of AI coding, but it's a fun learning experience and helps keep me technically grounded, and I'll carry on with it for as long as those things remain true.

themafia 2 days ago

> I don't know how useful projects like Anos are any more

They have the same utility they always have. They help you and the people you share it with learn. So it's exceedingly useful.

> given we now live in the age of AI coding

We live in an age of AI overinvestment. I would reserve judgement until they prove they actually have something.

  • noone_youknow 2 days ago

    > We live in an age of AI overinvestment. I would reserve judgement until they prove they actually have something.

    Haha yes, that's a very fair comment!

wamatt 2 days ago

Oh boy.. this is a perfect Show HN to wake up to :)

With the wild pace of everything going on right now. I can’t be alone feeling it truly captures the hacker spirit. Echoes to early Lisp days, or maybe my high school side quest to learn Minix? Ie building from scratch and seeing what’s possible.

Sadly most of us will never have the staying power (well definitely not myself) and yet you gave us a little window into your passion.

Thank you for the inspiration. Especially the focus on compounding small wins and including us in your orbit. Long live Anos

  • noone_youknow a day ago

    Thank you! A project like this is all about compounding small wins for sure, just building one thing on top of the previous thing until (hopefully) one day it’s a complete thing :D

    I’m glad you found some inspiration and really appreciate your kind comment :)

  • the_biot a day ago

    Nah, it's just AI slop, despite OP's "hand-written" protestation.

jonpalmisc 2 days ago

Going to take a guess the author is not a Spanish speaker :p

  • pezezin 2 days ago

    After Nvidia's cuLitho now we get Anos...

  • rurban 2 days ago

    Ross Bamford doesn't sound spanish to me

    • pezezin 2 days ago

      José is not an English name and here I am writing in English. People can learn other languages you know?

jason1cho 2 days ago

I love the adjective "hand-written" and I'm gonna add it to my repositories.

Although I don't practice vibe coding, I'v observed that the first principle of vibe coding is to never look at the generated code. (You learn the code from external metrics, such output correctness and memory usage)

rurban 2 days ago

> Anos is a modern, opinionated, non-POSIX operating system (just a hobby, won't be big and professional like GNU-Linux®) for x86_64 PCs and RISC-V machines.

Love that Linus quip! Hopefully it will be. Non-POSIX sounds exciting

  • noone_youknow 2 days ago

    Haha that quote felt pretty much obligatory :D Non-POSIX is definitely keeping things fun, letting me explore different ideas without having to fit into an existing interface design :)

    • adrian_b 2 days ago

      While not basing the OS on POSIX is good, if you ever want to use it for more than a hobby, i.e. if you ever want to use it for your main personal computer, you will also need a translation layer for the LINUX syscalls, which would enable you to compile and run any of the existing open-source programs, or even run existing binaries.

      Porting the programs that you are more interested in from Linux or *BSD to your own OS is the best, but this is necessarily slow and also the work of porting rarely used applications may not be worthwhile.

      An alternative to a syscall translation layer is for your OS to act as a hypervisor for Linux or other OSes VMs. However, this would have a lower performance than using natively your IPC-based OS.

      • noone_youknow 2 days ago

        I agree that for it to be generally useful, it’ll need to be easy to port existing software to. But I don’t think I’ll need a translation layer at the syscall level (unless I want to expose a Linux-compatible ABI as you suggest, which is totally a non-goal).

        You can get surprisingly far in this area with a decent libc implementation - once you have that porting a lot of things becomes possible. There will always be harder problems (e.g. anything that hard-depends on fork) but with enough work pretty much anything in user-space should be possible to port eventually.

        I’m using newlib for libc, with a custom Anos-specific libgloss that mostly talks to SYSTEM via IPC to get stuff done, and uses syscalls where needed (and a process has the appropriate capabilities). I’m filling out that low-level interface as I go, and will be using porting of exiting BSD or Linux software to drive that implementation :)

        • adrian_b 2 days ago

          I agree that instead of implementing the Linux syscalls implementing just those libc functions that are OS dependent is sufficient for a large fraction of the existing programs.

          However, this means implementing a POSIX layer, similarly to Windows NT. So it is a solution more distant from a "non-POSIX operating system".

          While a large part of the Linux syscalls have been motivated by the necessities of implementing POSIX, there are also significant differences and the Linux applications that require the best performance must deviate significantly from POSIX, so they are no longer based on libc for I/O.

          • noone_youknow a day ago

            There would likely be value in a POSIX layer as you describe, at least from the point of view of porting existing programs. And perhaps it will happen, if I get far enough along, but it will never be a kernel feature - it would be an entirely userspace concept intended only to speed up porting and building out said user space.

            Perhaps in the fullness of time essential software can be rewritten to Anos’ “native API”, or perhaps that’s a pipe dream and not worth the work, but the option will be there.

rstat1 2 days ago

In my opinion if you learned something from it, it was useful. Bonus points if others learn from it as well, but if not then as long as you did then it doesn’t matter. AI age or not.

I’ve always found hobby OS projects like this interesting, and I hope there’s never a shortage of them in the future

  • noone_youknow 2 days ago

    That's a good way to look at it, and on reflection I feel the same way.

    It's certainly useful _to me_ and has helped me really nail down concepts I thought I already understood, but it turns out I didn't.

    I just hope that, in an age where it feels like code, and maybe even deep technical knowledge have diminishing value, projects like this don't become completely anachronistic.

AbraKdabra 2 days ago

> I don't know how useful projects like Anos are any more

I get pretty excited when project like Anos come out, I love Anos. Long live all Anos.

thomasjudge 2 days ago

The comment in the "high level overview" section - "(just a hobby, won't be big and professional like GNU-Linux®)" is an amusing reference

avadodin 2 days ago

Is this inspired by any particular micro-kernel design?

Looking at syscalls.h, it looks like it abstracts the platform details, for example.

Is SYSTEM for amd64 source-compatible with the riscv version?

  • noone_youknow 2 days ago

    There's ideas in here from various other kernels - some of the capability stuff is inspired by (but simpler than) seL4, and the message passing IPC and how I'll avoid priority inversion is based on ideas from QNX. Generally as a learning process I've tried to keep as open a mind as possible, without trying to reinvent all the wheels at once...

    SYSTEM has a tiny arch-specific assembly trampoline which just sets up the initial stack pointer for new processes that it creates and makes the jump, but other than that it's source-compatible across architectures.

    The platform detail extraction isn't yet complete, such that devices management on non-ACPI platforms isn't finished, but the idea is the abstraction will be enough that drivers for (at least) MMIO devices will be trivially portable.

hgpuke 2 days ago

Interesting project! When it is finished, what are your plans for it?

  • noone_youknow 2 days ago

    Thanks! I haven't thought much about long term to be honest, right now my immediate goal is to get enough USB HID to be able to make it interactive, with the medium term goal of porting enough software for it being self-hosting.

rgbrgb 2 days ago

impressive. how do you pronounce it?

snvzz 2 days ago

Roscopeco... also behind rosco-m68k.