Why we should read UNIX 6th source code
Introduction
Lately, I finished writing the note of UNIX 6th code reading.
I recommend you to read the UNIX 6th source codes, too.
I'll show you why it's so worthy, here.
Summary
UNIX 6th is appropriate for who has never read the source code of OS.
Begin to read it A.S.A.P!
You can read the source code here.
The reason why I recommend you to read UNIX 6th source code
The number of lines is just only about 10,000
The number of lines of recent Linux source code is over than 1,000,000. It's very hard for us to understand it overall.
The other hand, the number of lines of UNIX 6th source code including device drivers is just about 10,000.
And the number of lines of each device driver source code is only about 100. They're very simple, so you can get to know the detail easily.
It includes fundamental ideas of OS
Unix 6th source code includes basic OS techniques.
File system, Process, Process switch( Context switch ), System call, Interrupt, Trap, Pipe, Device driver, and so on. They're implemented as simple logics.
A recent OS source code has been modified and sophisticated. So you can't easily understand what they do, i think.
Understanding UNIX 6th will help you understand them because you can guess what they do if you have basic ideas of OS.
As you know UNIX 6th was written many years ago. So, be careful that it doesn't include recent techniques. For example, Network, Thread, logic for Multiprocessing, and so on.
The guide book exists
The guide book for reading UNIX 6th code exists. That is "Lions' Commentary on UNIX" called "Lions Book" by some people.
If you can't afford to buy it, you can get the pdf files for free because it's published by the author on internet. I'll introduce you the web site below.
And I've attended the workshop of the Lions Book since 2010. Please feel free to join it if you're interested in it.
Besides, of course, you can refer to my blog articles to read the code. I believe they help you understand.
Sufficient materials
You can get the sufficient UNIX 6th and PDP11 materials on internet.
I'll introduce you the web site you can get materials later.
Besides the emulator of UNIX 6th and PDP11 exists. You can read the source code with actually operating UNIX 6th. (How nice!) You can get the information of it here.
It helps your job well
As you know, OS is the basement of a computer system.
Understanding OS helps you understand how hardwares are used.
Understanding OS helps you understand how programs are handled.
That is, it's beneficial for both hardware engineers and software engineers. You can guess what the bottle neck is in a system if you have the knowledge of OS.
In other words, understanding OS helps you understand a computer system all over.
Problems
Yap, of course we have some problems to read UNIX 6th source code.
First, pre K&R C. Most code readers are confused by it. I'll show you one of the examples.
struct { char high ; char low ; } ; hogehoge( arg ) { int hoge ; hoge = arg ; return hoge->low ; }
I expect that you're confused now like "Why types aren't written at hogehoge( ) function and arg arguments!?", "Why integer hoge can use hoge->low!?". But, that is pre K&R C!
Second, some programs are written in assembly code. I guess it must be very serious problems for some people. I tried understood some of them and wrote the descriptions on my blog. I believe they help you understand.
Third, some of the source codes aren't sophisticated yet.
Finally, it's not so easy to understand Lions Book. See my articles when you can't understand it. You're required not to mind them too much. :-)
My articles
Basically I followed the flow of the Lions Book. The line numbers written in the articles are corresponding to the source code ones used in Lions Book.
- UNIX 6th Code Reading articles and relaring articles(written in japanese)
- 2010-10-24 UNIX 6th code reading - malloc
- 2010-11-07 UNIX 6th code reading - mfree
- 2010-11-23 UNIX 6th code reading - prf.c
- 2010-12-12 UNIX 6th code reading - virtual address
- 2010-12-12 UNIX 6th code reading - boot
- 2010-12-18 UNIX 6th code reading - main
- 2010-12-30 UNIX 6th code reading - sched - /etc/init実行まで
- 2010-12-30 UNIX 6th code reading - 6章まとめ
- 2011-01-08 UNIX 6th code reading - プロセス
- 2011-01-16 UNIX 6th code reading - プロセス管理
- 2011-01-30 UNIX 6th code reading - 割り込みとトラップの概要
- 2011-02-09 UNIX 6th code reading - 割り込み・トラップルーチン
- 2011-02-10 UNIX 6th code reading - 割り込み・トラップルーチンその2
- 2011-02-11 UNIX 6th code reading - クロック割り込み
- 2011-02-14 UNIX 6th code reading - PDP11割り込みに関するまとめ
- 2011-02-20 UNIX 6th code reading - trap.c
- 2011-03-06 UNIX 6th code reading - システムコール
- 2011-03-20 UNIX 6th code reading - fork
- 2011-03-21 UNIX 6th code reading - ソフトウェア割り込み(シグナル)
- 2011-03-21 UNIX 6th code reading - signalシステムコール
- 2011-03-26 UNIX 6th code reading - signalシステムコール続き
- 2011-03-26 UNIX 6th code reading - トレース
- 2011-04-03 UNIX 6th code reading - スワッピング
- 2011-05-21 UNIX 6th code reading - 基本入出力入門
- 2011-06-04 UNIX 6th code reading - RKディスクドライバ
- 2011-06-12 UNIX 6th code reading - バッファ
- 2011-06-27 UNIX 6th code reading - バッファの状態遷移
- 2011-06-28 UNIX 6th code reading - ディスクキャッシュの効率化
- 2011-08-15 UNIX 6th code reading - ファイルシステム概要
- 2011-08-20 UNIX 6th code reading - ファイルシステム概要その2
- 2011-10-26 UNIX 6th code reading - mount
- 2011-11-26 UNIX 6th code reading - unix/alloc.c
- 2011-12-11 UNIX 6th code reading - unix/iget.c
- 2011-12-19 UNIX 6th code reading - unix/namei.c
- 2011-12-25 UNIX 6th code reading - unix/subr.c
- 2011-12-25 UNIX 6th code reading - unix/fio.c
- 2011-12-25 UNIX 6th code reading - unix/rdwri.c
- 2011-12-30 UNIX 6th code reading - unix/sys2.c
- 2011-12-30 UNIX 6th code reading - unix/sys3.c
- 2011-12-31 UNIX 6th code reading - パイプ
- 2012-01-01 UNIX 6th code reading - キャラクタデバイスドライバ
- 2012-01-01 UNIX 6th code reading - buffer pool
- 2012-01-02 UNIX 6th code reading - 対話型端末
- 2012-01-02 UNIX 6th code reading - 対話型端末その2
And I've tried translating them into English. I'm afraid but, I haven't finished yet. If you want to read A.S.A.P, please cheer and support me. :-)
- UNIX 6th Code Reading articles(tranfered into english)
The following list is the note of the work shop of Lions book I introduced you the above.
- the note of the work shop Lions' Commentary on UNIX(written in japanese)
- 2010-10-31 Lions’ Commentary on UNIX 読書会メモ#1
- 2010-12-05 Lions’ Commentary on UNIX 読書会メモ#2
- 2011-01-30 Lions’ Commentary on UNIX 読書会メモ#3
- 2011-02-20 Lions’ Commentary on UNIX 読書会メモ#4
- 2011-03-29 Lions’ Commentary on UNIX 読書会メモ#5
- 2011-04-11 Lions’ Commentary on UNIX 読書会メモ#6
- 2011-05-28 Lions’ Commentary on UNIX 読書会メモ#7
- 2011-06-19 Lions’ Commentary on UNIX 読書会メモ#8
- 2011-06-25 Lions’ Commentary on UNIX 読書会メモ#8 おさらい
- 2011-07-02 Lions’ Commentary on UNIX 読書会メモ#8 おさらい その2
- 2011-08-28 Lions’ Commentary on UNIX 読書会メモ#10
- 2011-09-21 Lions’ Commentary on UNIX 読書会メモ#11
- 2011-12-03 Lions’ Commentary on UNIX 読書会メモ#12
- 2011-12-03 Lions’ Commentary on UNIX 読書会メモ#13
These articles are the notes of the camp that is took place with the work shop members.
- the note of the camp(witten in japanese)
- 2011-10-13 どんなときにpanicで落ちる?UNIX V6の話(Lions本合宿のLTネタ)
- 2011-10-22 合宿の成果発表時に使用した資料&togetterまとめ
I've tried making some software and doing experiments regarding to UNIX 6th.
- my lab(written in japanese)
- 2011-04-19 UNIX 6thに足し算システムコールを追加してみた
- 2011-08-24 HTML5とC++で、それぞれUNIX v6のファイルシステムハック始めました
- 2011-08-27 UNIX V6 file system hack toolの現状を動画で紹介
- 2011-08-30 UNIX V6 file system hack toolのC++版の現状を動画で紹介
- 2011-12-04 UNIX v6で削除したファイルの復元をしてみた
- 2012-01-05 UNIX 6th a.out cheat sheet