Rust로 OS 구현하기
이 블로그 시리즈는 Rust 프로그래밍 언어로 작은 OS를 구현하는 것을 주제로 합니다. 각 포스트는 구현에 필요한 소스 코드를 포함한 작은 튜토리얼 형식으로 구성되어 있습니다. 소스 코드는 이 블로그의 Github 저장소에서도 확인하실 수 있습니다.
최신 포스트: Async/Await
CPU 예외 (Exception)
CPU 예외 (exception)는 유효하지 않은 메모리 주소에 접근하거나 분모가 0인 나누기 연산을 하는 등 허용되지 않은 작업 실행 시 발생합니다. CPU 예외를 처리할 수 있으려면 예외 처리 함수 정보를 제공하는 인터럽트 서술자 테이블 (interrupt descriptor table; IDT) 을 설정해 두어야 합니다. 이 글에서는 커널이 breakpoint 예외를 처리한 후 정상 실행을 재개할 수 있도록 구현할 것입니다.
더 읽기 »더블 폴트 (Double Fault)
이번 글에서는 CPU가 예외 처리 함수를 호출하는 데에 실패할 때 발생하는 더블 폴트 (double fault) 예외에 대해 자세히 다룹니다. 더블 폴트 예외를 처리함으로써 시스템 재부팅을 발생시키는 치명적인 트리플 폴트 (triple fault) 예외를 피할 수 있습니다. 트리플 폴트가 발생할 수 있는 모든 경우에 대비하기 위해 Interrupt Stack Table 을 만들고 별도의 커널 스택에서 더블 폴트를 처리할 것입니다.
더 읽기 »Introduction to Paging
This post introduces paging, a very common memory management scheme that we will also use for our operating system. It explains why memory isolation is needed, how segmentation works, what virtual memory is, and how paging solves memory fragmentation issues. It also explores the layout of multilevel page tables on the x86_64 architecture.
더 읽기 »Paging Implementation
This post shows how to implement paging support in our kernel. It first explores different techniques to make the physical page table frames accessible to the kernel and discusses their respective advantages and drawbacks. It then implements an address translation function and a function to create a new mapping.
더 읽기 »Heap Allocation
This post adds support for heap allocation to our kernel. First, it gives an introduction to dynamic memory and shows how the borrow checker prevents common allocation errors. It then implements the basic allocation interface of Rust, creates a heap memory region, and sets up an allocator crate. At the end of this post, all the allocation and collection types of the built-in alloc
crate will be available to our kernel.
Allocator Designs
This post explains how to implement heap allocators from scratch. It presents and discusses different allocator designs, including bump allocation, linked list allocation, and fixed-size block allocation. For each of the three designs, we will create a basic implementation that can be used for our kernel.
더 읽기 »Async/Await
In this post, we explore cooperative multitasking and the async/await feature of Rust. We take a detailed look at how async/await works in Rust, including the design of the Future
trait, the state machine transformation, and pinning. We then add basic support for async/await to our kernel by creating an asynchronous keyboard task and a basic executor.
Subscribe
Receive notifications about new posts and other major changes! You can either:
- Subscribe to our RSS/Atom Feed,
- Subscribe to this GitHub issue, or
- Subscribe to our email newsletter.
Status Updates
These posts give a regular overview of the most important changes to the blog and the tools and libraries behind the scenes.
First Edition
You are currently viewing the second edition of “Writing an OS in Rust”. The first edition is very different in many aspects, for example it builds upon the GRUB bootloader instead of using the `bootloader` crate. In case you're interested in it, it is still available. Note that the first edition is no longer updated and might contain outdated information. read the first edition »
Support Me
Creating and maintaining this blog and the associated libraries is a lot of work, but I really enjoy doing it. By supporting me, you allow me to invest more time in new content, new features, and continuous maintenance. The best way to support me is to sponsor me on GitHub. Thank you!