Hacker News new | ask | show | jobs
by MisterTea 326 days ago
> It would be neat if there was a standard interface for device drivers, similar to what POSIX does for user-space.

Plan 9 does this but instead of a binary interface that exposes machine details it hides them behind 9P, a simple RPC file tree protocol. This same protocol is also served by user space programs so it's universal. The benefit of all this is the system is small and very light weight. Its an OS a single human can grok from kernel to user space.

Since 9p abstracts everything it's kernel and language agnostic. A Plan 9 kernel can be written in Rust and serve the same 9P tree to a Plan 9 written in C, Go, Zig, D, etc. The user space drivers and services can also be written in any language as well as the programs accessing them. 9P is machine agnostic so a Plan 9 network can be made of disparate machine architectures letting you mix x86, Arm, Power, Mips, Risc-V, etc. Stupid simple cross compiling is an out of the box feature, just change the objtype env variable.

I can export those devices/services to other systems using 9P, cifs, nfs, and so on. I can export the sound device of a Plan 9 machine using cifs to a Windows box and a Windows program could open that file and play sound by writing 16bit stereo audio to it.

Your data structures are then pretty strait forward, e.g audio(3): "Audio data is a sequence of stereo samples, left sample first. Each sample is a 16 bit little-endian two's complement integer; the default sampling rate is 44.1 kHz." http://man.postnix.pw/9front/3/audio

It's a fantastic concept which frees all the services and hardware from the confines of a old school POSIX/Unix machine. Since Plan 9 in NOT Unix you also don't have to worry about crusty old POSIX. It has its own C dialect that is mostly C99 compliant and a very nice C library that beats smelly old ANSI C. I highly recommend learning how it works and giving it a go. Its not for everyone but man, I really dig how its just a patch-bay of networked 9P stuff. Wiring up a network of machines and hardware is ezpz.

1 comments

I was always fascinated by plan 9 ever since finding out about it and only ever having heard of the movie referenced in Seinfeld. Way back then I didn’t think it would keep seeing use and development, I’m glad I’m wrong :)