RustでOSを書く
このブログシリーズでは、ちょっとしたオペレーティングシステムをRustプログラミング言語を使って作ります。それぞれの記事が小さなチュートリアルになっており、必要なコードも全て記事内に記されているので、一つずつ読み進めて行けば理解できるでしょう。対応したGithubリポジトリでソースコードを見ることもできます。
最新記事: Async/Await
CPU例外
CPU例外は、例えば無効なメモリアドレスにアクセスしたときやゼロ除算したときなど、様々なミスによって発生します。それらに対処するために、ハンドラ関数を提供する 割り込み記述子表 を設定しなくてはなりません。この記事を読み終わる頃には、私達のカーネルはブレークポイント例外を捕捉し、その後通常の実行を継続できるようになっているでしょう。
もっと読む »Double Faults
この記事ではCPUが例外ハンドラの呼び出しに失敗したときに起きる、ダブルフォルト例外について詳細に見ていきます。この例外を処理することによって、システムリセットを起こす重大なトリプルフォルトを避けることができます。あらゆる場合においてトリプルフォルトを防ぐために、ダブルフォルトを異なるカーネルスタック上でキャッチするための割り込みスタックテーブルをセットアップしていきます。
もっと読む »Hardware Interrupts
In this post we set up the programmable interrupt controller to correctly forward hardware interrupts to the CPU. To handle these interrupts we add new entries to our interrupt descriptor table, just like we did for our exception handlers. We will learn how to get periodic timer interrupts and how to get input from the keyboard.
もっと読む »ページング入門
この記事ではページングを紹介します。これは、私達のオペレーティングシステムにも使う、とても一般的なメモリ管理方式です。なぜメモリの分離が必要なのか、セグメンテーションがどういう仕組みなのか、仮想メモリとは何なのか、ページングがいかにしてメモリ断片化の問題を解決するのかを説明します。また、x86_64アーキテクチャにおける、マルチレベルページテーブルのレイアウトについても説明します。
もっと読む »ページングの実装
この記事では私達のカーネルをページングに対応させる方法についてお伝えします。まずページテーブルの物理フレームにカーネルがアクセスできるようにする様々な方法を示し、それらの利点と欠点について議論します。次にアドレス変換関数を、ついで新しい対応付けを作るための関数を実装します。
もっと読む »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
この記事では、Rustの協調的マルチタスクとasync/await機能について説明します。Rustのasync/await機能については、Future
trait の設計、ステートマシンの変換、 pinning などを含めて詳しく説明します。そして、非同期キーボードタスクと基本的なexecutorを作成することで、カーネルにasync/awaitの基本的なサポートを追加します。
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, since they don't charge any fees. If you prefer other platforms, I also have Patreon and Donorbox accounts. The latter is the most flexible as it supports multiple currencies and one-time contributions.
Thank you!