6.828: Operating System Engineering (25)
Lab2 突入。昨晩エントリなソレを実行。
以下なカンジ。
$ git status # On branch lab1 # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: GNUmakefile # modified: kern/kdebug.c # modified: kern/monitor.c # modified: lib/printfmt.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # core # init.d # init.s # jos.in # jos.out # obj/ no changes added to commit (use "git add" and/or "git commit -a") $
上のだけ add します。
$ git add GNUmakefile kern/kdebug.c kern/monitor.c lib/printfmt.c $ git commit -am 'my solution to lab1' [lab1 668eb13] my solution to lab1 4 files changed, 58 insertions(+), 5 deletions(-) $
で、pull して checkoub するのか。
$ git pull Already up-to-date. $ git checkout -b lab2 origin/lab2 Branch lab2 set up to track remote branch lab2 from origin. Switched to a new branch 'lab2' $
なるほど、今後はリモートブランチを使う形で進んでいくのか。
$ git branch -a lab1 * lab2 remotes/origin/HEAD -> origin/lab1 remotes/origin/lab1 remotes/origin/lab2 remotes/origin/lab3 remotes/origin/lab4 remotes/origin/lab5 remotes/origin/lab6 remotes/origin/lab7 $
lab1 と merge します。
$ git merge lab1 Auto-merging GNUmakefile Merge made by recursive. GNUmakefile | 1 + kern/kdebug.c | 3 ++- kern/monitor.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/printfmt.c | 8 ++++---- 4 files changed, 58 insertions(+), 5 deletions(-) $
本題
Memory Management というタイトルですね。以下なファイルが追加になっているとのこと。
- inc/memlayout.h
- kern/pmap.c
- kern/pmap.h
- kern/kclock.h
- kern/kclock.c
む、inc/mmu.h もポイント高いとか書いてありますが如何に。
Exercise 1
kern/pmap.c で定義される以下を実装せよ、とのこと。
- boot_alloc()
- page_init()
- page_alloc()
- page_free()
pmap.c は他にも空っぽなのがいくつかあるようですが、とりあえず上記らしい。あ、i386_vm_init() 手続きも対象範疇内か。ちょっと色々資料を見つつ pmap.c とかを掘削した方が良いのかどうか。
諸々確認してみたところ、init.c の i386_init 手続きが以下になってて
void i386_init(void) { extern char edata[], end[]; // Before doing anything else, complete the ELF loading process. // Clear the uninitialized global data (BSS) section of our program. // This ensures that all static/global variables start out zero. memset(edata, 0, end - edata); // Initialize the console. // Can't call cprintf until after we do this! cons_init(); cprintf("6828 decimal is %o octal!\n", 6828); // Lab 2 memory management initialization functions i386_detect_memory(); i386_vm_init(); // Drop into the kernel monitor. while (1) monitor(NULL); }
i386_detect_memory() 手続きと i386_vm_init() 手続きは pmap.c で定義されてる模様。ちなみに最初の状態だと i386_vm_init() 手続きは以下になってて
void i386_vm_init(void) { pde_t* pgdir; uint32_t cr0; size_t n; // Delete this line: panic("i386_vm_init: This function is not finished\n");
とりあえず panic しちゃう模様。このあたりは帰ってうにまがの例のアレとかを見つつ検討した方が良さげなカンジがしてます。