While Microsoft and Apple don’t release the source code for their operating systems, a good estimate is that it takes around 50 million lines of code to run these software behemoths. The Linux kernel alone holds around 30 million lines, with systemd containing over one million lines on its own, which doesn’t include estimates for the desktop environment or other parts of a standard installation. But millions of lines of code, or even hundreds of thousands, aren’t necessary for building a fully functioning operating system. This one sets up a complete OS in exactly 2000 lines of code.
Called egos-2000, short for Earth and Grass Operating System, the diminutive operating system is written for RISC-V computers and while it does contain most of the tools we would recognize in an OS, it was built specifically for computer science students by PhD candidate Yunhao Zhang. The slimmed-down operating system makes it possible for students to easily read and understand every feature of an operating system without it becoming too overwhelming, and can be easily used and modified to experiment with. The name itself comes from its design principles, where parts of the operating system that interact with hardware directly are part of the “Earth” layer and parts that don’t depend on hardware being placed in the “Grass” layer, with applications taking up a third layer.
The OS is available on this GitHub page under an MIT license and works on real RISC-V hardware as well as within various emulators. Building a complete operating system in so few lines of code is an impressive feat, and making it comprehensive enough to teach students with goes well beyond that accomplishment as well. Often when concepts in computer science are reduced to their bare minimum components, we end up with completely illegible (but interesting) experiments like this programming language instead.
ISTR, A.S. Tanenbaum had each student write an OS for a class he taught.
https://en.m.wikipedia.org/wiki/Andrew_S._Tanenbaum
Tanebaum was the go-to text when I studied.
We were tasked with hacking MINIX.
IIRC I made the TTY module re-entrant so you could have multiple terminals hanging off your 8088 PC… Fun times.
Apparently, Intel adapted MINIX for the Intel Management Engine used on modern x86/x84 processors.
What is ISTR and why didn’t you spell it out?
I Seem To Recall,
but YMMV
What is a OS?
A miserable little pile of secrets! [Tosses sniffer of brandy to the ground] But enough talk, have at you!
Looks like someone has been abusing the joystick with RetroPie lately…
👍
ROTFL
Oxydative stress
https://www.acronymfinder.com/OS.html
“While Microsoft and Apple don’t release the source code for their operating systems”
https://github.com/microsoft/MS-DOS
And darwin is available in source format also
Code is full of busy waiting calls, like in the UART driver. It should really have a task switch there to deserve the name of Operating System.
You are right and I won’t claim myself that egos-2000 is a complete OS. I’m the author BTW. It barely contains everything we wish to teach our undergrads for education purposes only.
Interrupt driven I/O seems apropos on a UART.
Emulators. :(
Sipeed risc-v hardware. :)
i rather like simple operating systems. i feel that things like windows, unix, linux, etc. try to do things far outside the scope of what an os should be. and technically you can strip any of those down to their cores and dispense with their software suites they call features and end up with something rather snappy. until some nasty dependency in some piece of software you need comes along that makes you re-install crap you got rid of in order to speed things up. such as getting rid of the app store just to find out a piece of software you need can only be obtained through the app store.
It’s impossible to avoid complexity when you want to have a very high performance and scalable system. Try building a large multicore system, with multiple network cards, that can handle 1M HTTP requests per second using a simple design.
Scalability means the ability to expand the workload without limit, so of course it requires complexity. Very high performance on a fixed type of single-threaded task does not require complexity, it requires the OS to load program and data, export results, and otherwise keep out of the way.
Between those extremes, most computer users never change their hardware and only add new programs occasionally. They have no need for thousands of drivers and the ability to have 32,000 threads active at once. Operating system bloat is caused by trying to meet everybody’s desires. and it degrades response time.
IOW, one size fits all, except when it doesn’t.
B^)
I somewhat disagree… It also depends on hardware and goals.. Eg SQL is very complicated for high performance scalable system, but some NoSQL approaches can be very simple and outperform the SQL at large scale… Different mindset.
If you have 1000+ Cores, preemptive multitasking may not be important, each core might have easy hardware way to send and receive messages to other cores. Memory model might have each block of memory either read only to all cores or read write to a single core, each core might have 64 kilobytes of local memory that no other core can touch other than by asking through messages.
Lots of issues simply don’t exist under different approaches… You lose stuff like no SQL loses compared to SQL, but you might be better off without it… Better to handle 10x the load but have some results a little outdated
Yes! It’s also impossible to avoid complexity when the lines between the OS and application level code become blurred with functionality that should be optional application features become embedded into the operating system.
“and technically you can strip any of those down to their cores and dispense with their software suites they call features and end up with something rather snappy. ”
That reminds me of Windows CE. It was stripped down below usability, often. It was pre-installed on those cheap ARM based nettops of the late 2000s.
i was thinking more of community driven images to slim the os, but ms has their own slim versions, like the hard to get ltsb versions and of course their iot offerings. ce is a good example though. their pre-smartphone pda os was kind of crap (i want to say pocket edition but im not sure).
these sorts of projects are myriad in academia. it’s definitely a lot easier to play with and do assignments against than most (all?) ‘real’ OSes.
and fwiw i still haven’t even read the lions book.
but personally i would advise people to read the linux 0.01 source. it’s about 10,000 lines of C and asm. it’s pretty readable, you don’t need to read every line to understand the shape of it. and it’s fairly complete and you can really see the seeds of modern linux there. it’s a pretty good introduction imo. yeah i’m really recomending a cover to cover skim of the whole thing shrug. less `find . -type f` (obviously you’ll want to jump around to answer questions as you go)
I wouldn’t exactly use Unix/Linux as a prime example of an OS. Too crusted and dated, too obsolete. Monolithic kernal etc. A relic of the 1960s, in short.
Better have a look at Amiga OS, CP/M or Atari TOS or BeOS/Haiku. These are fresh, young OSes.
“These are fresh, young OSes”
Did I miss your sarcasm?
They’re dead, Jim!
I might be missing something in the repo, but what hardware exactly does this run on?
usages.md says it will run on a Artix-7 35T fpga dev board.
From the photo it is a Digilent Arty A7.
I would love to see stripped down linux kernel actually for ie the classical thinkpad x220 with libreboot and co.
How much can you tear off and keep it functional and coherent ?
Extremely intellectual comments