yhzhang0128/egos-2000

Envision a future where everyone can read all the code of an educational operating system.

3,609

stars

1,216

commits

C

primary language

Aug 16, 2026

updated

egos.fun/
education
operating-system

README

Vision

This project's vision is to help every student read all the code of a teaching operating system.

With only 2000 lines of code, egos-2000 implements every component of a teaching operating system that runs on both QEMU and RISC-V boards. The EGOS book contains 9 course projects based on egos-2000.

Fail to load an image of egos-2000.

# The cloc utility is used to count the lines of code.
> cloc egos-2000 --exclude-ext=md
...
github.com/AlDanial/cloc v 1.94  T=0.05 s (949.3 files/s, 62349.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               30            453            677           1592
C/C++ Header                     9             64            105            258
Assembly                         3             14             46             92
make                             1             17             10             58
-------------------------------------------------------------------------------
SUM:                            43            548            838           2000 (exactly!)
-------------------------------------------------------------------------------

Earth and Grass Operating System

The "egos" part of egos-2000 is named after its three-layer architecture.

  • The earth layer implements hardware-specific abstractions.
    • tty and disk device interface
    • timer and memory management interface
  • The grass layer implements hardware-independent abstractions.
    • process control block and system call interface
  • The application layer implements file system, shell, and user commands.

The definitions of struct earth and struct grass in the header file egos.h specify the layer interface. Please read USAGES.md for running egos-2000, and the instruction set manuals for the RISC-V privileged ISA.

Acknowledgements

Many thanks to Meta for a Facebook fellowship. Many thanks to Robbert van Renesse, Lorenzo Alvisi, Shan Lu, Hakim Weatherspoon and Christopher Batten for their support. Many thanks to Cheng Tan and Yu-Ju Huang for providing valuable feedback on the EGOS book and using egos-2000 in Northeastern CS4973/6640 and Cornell CS4411/5411. Many thanks to Haobin Ni and Hongbo Zhang for porting egos-2000 to mriscv, a simple processor written in SystemVerilog. Many thanks to Brandon Fusi for porting egos-2000 to Allwinner D1 and Sipeed's Lichee RV64 Nezha compute module. Many thanks to Zack Light for making a YouTube video introducing egos-2000, and many thanks to Christopher Allison for making the DOOM video game work on egos-2000.

For any questions, please contact Yunhao Zhang.

Contributors

yhzhang0128

1,198 commits

yacyam

10 commits

sdsalyer

2 commits

yhzhang0128/egos-2000

Envision a future where everyone can read all the code of an educational operating system.

3,609

stars

1,216

commits

C

primary language

Aug 16, 2026

updated

egos.fun/
education
operating-system

README

Vision

This project's vision is to help every student read all the code of a teaching operating system.

With only 2000 lines of code, egos-2000 implements every component of a teaching operating system that runs on both QEMU and RISC-V boards. The EGOS book contains 9 course projects based on egos-2000.

Fail to load an image of egos-2000.

# The cloc utility is used to count the lines of code.
> cloc egos-2000 --exclude-ext=md
...
github.com/AlDanial/cloc v 1.94  T=0.05 s (949.3 files/s, 62349.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
C                               30            453            677           1592
C/C++ Header                     9             64            105            258
Assembly                         3             14             46             92
make                             1             17             10             58
-------------------------------------------------------------------------------
SUM:                            43            548            838           2000 (exactly!)
-------------------------------------------------------------------------------

Earth and Grass Operating System

The "egos" part of egos-2000 is named after its three-layer architecture.

  • The earth layer implements hardware-specific abstractions.
    • tty and disk device interface
    • timer and memory management interface
  • The grass layer implements hardware-independent abstractions.
    • process control block and system call interface
  • The application layer implements file system, shell, and user commands.

The definitions of struct earth and struct grass in the header file egos.h specify the layer interface. Please read USAGES.md for running egos-2000, and the instruction set manuals for the RISC-V privileged ISA.

Acknowledgements

Many thanks to Meta for a Facebook fellowship. Many thanks to Robbert van Renesse, Lorenzo Alvisi, Shan Lu, Hakim Weatherspoon and Christopher Batten for their support. Many thanks to Cheng Tan and Yu-Ju Huang for providing valuable feedback on the EGOS book and using egos-2000 in Northeastern CS4973/6640 and Cornell CS4411/5411. Many thanks to Haobin Ni and Hongbo Zhang for porting egos-2000 to mriscv, a simple processor written in SystemVerilog. Many thanks to Brandon Fusi for porting egos-2000 to Allwinner D1 and Sipeed's Lichee RV64 Nezha compute module. Many thanks to Zack Light for making a YouTube video introducing egos-2000, and many thanks to Christopher Allison for making the DOOM video game work on egos-2000.

For any questions, please contact Yunhao Zhang.

Contributors

yhzhang0128

1,198 commits

yacyam

10 commits

sdsalyer

2 commits

Languages

C

91.8%

Makefile

3.6%

Assembly

3.2%

Linker Script

1.5%