Yunhao Zhang's Egos-2000 Packs an Entire RISC-V Operating System Into Just 2,000 Lines of Code

Designed to make it possible for students to learn about every aspect of OS development, egos-2000 is a miniature marvel.

Gareth Halfacree
2 years ago β€’ Productivity / FPGAs

Software engineer and Cornell PhD candidate Yunhao Zhang has developed an operating system with a difference: packing its features into just 2,000 lines of code, egos-2000 aims to offer an understandable platform for low-level computing education.

"This project's vision is to help every college student read all the code of an operating system," Zhang explains of his creation. "With only 2,000 lines of code, egos-2000 implements every component of an operating system for education. It can run on a RISC-V board and also the QEMU software emulator."

While the name may appear to be based on "ego," egos-2000 is actually named for two of its three layers. The "Earth and Grass Operating System" puts hardware-specific abstractions, including memory management and disk interface work, in the "earth layer," and hardware-independent abstractions, including processes and system calls, in the "grass layer." A final layer, the application layer, does exactly what the name suggests, implementing user-level stuff including the shell and user commands.

"We use egos-classic and egos-2000 as our teaching OS at Cornell," Zhang explains. Where egos-classic aims at traditional computer architectures, though, egos-2000 is a more compact variant for chips based on the free and open-source RISC-V architecture. Measuring 2,000 lines of code exactly β€” as counted by the cloc utility, and primarily written in C with some assembly for good measure β€” it's compatible with a RISC-V core running on an FPGA development board or on an emulated core running in the QEMU emulator.

The egos-2000 source code is available on GitHub under the permissive MIT license, and comes complete with a copy of Zhang's teaching plan for Cornell's Practicum in Operating Systems (CS4411).

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles