6.828: Operating System Engineering (32)

免許更新の講習開始一時間前。電源確保して確認開始。ええと俯瞰が必要ってことでそれを意識しつつ、とゆーことで。

いくつかメモ

  • pages が指す配列も boot_alloc で確保が必要なのか。
    • boot_alloc(npage*sizeof(struct Page), PGSIZE) みたいなカンジ?
  • page_init で_使えない_位置の pp_ref を云々ってあるけど、スデに boot_alloc 済みのソレ達ってどうやって判別するの?
    • end から boot_freemem - 1 までは NG ってのは分かるな
      • 正しくは EXTPHYSMEM から boot_freemem -1 か
    • check_page_alloc 見れば page_init 終了時点での状態がどうなっていないと駄目か、が分かるはず

うーん、check_page_alloc 手続きの

	// if there's a page that shouldn't be on
	// the free list, try to make sure it
	// eventually causes trouble.
	LIST_FOREACH(pp0, &page_free_list, pp_link)
		memset(page2kva(pp0), 0x97, 128);

が何を意図して書かれてるのかが分からん。これで以降の assert のどれかが失敗するのを確認せよ、ってことなのかなぁ。

どうも手が動かない

これが

	for (i = 0; i < n; i += PGSIZE)
		assert(check_va2pa(pgdir, UPAGES + i) == PADDR(pages) + i);

邪魔してます。ここのマッピングは別途で、って理解で良いのかな。

とりあえず

手を動かしてみます。まず boot_alloc 手続きが以下。

static void*
boot_alloc(uint32_t n, uint32_t align)
{
	extern char end[];
	void *v;

	// Initialize boot_freemem if this is the first time.
	// 'end' is a magic symbol automatically generated by the linker,
	// which points to the end of the kernel's bss segment -
	// i.e., the first virtual address that the linker
	// did _not_ assign to any kernel code or global variables.
	if (boot_freemem == 0)
		boot_freemem = end;

	// LAB 2: Your code here:
	//	Step 1: round boot_freemem up to be aligned properly
	//		(hint: look in types.h for some handy macros)
	//	Step 2: save current value of boot_freemem as allocated chunk
	//	Step 3: increase boot_freemem to record allocation
	//	Step 4: return allocated chunk
	v = ROUNDUP(boot_freemem, align);
	boot_freemem += n;

	return v;
}

panic させてません。判断基準が分かり次第盛り込み予定。あと、i386_vm_init 手続きですが、

	//////////////////////////////////////////////////////////////////////
	// Allocate an array of npage 'struct Page's and store it in 'pages'.
	// The kernel uses this array to keep track of physical pages: for
	// each physical page, there is a corresponding struct Page in this
	// array.  'npage' is the number of physical pages in memory.
	// User-level programs will get read-only access to the array as well.
	// Your code goes here:
	pages = boot_alloc(npage*sizeof(struct Page), PGSIZE);


	//////////////////////////////////////////////////////////////////////
	// Now that we've allocated the initial kernel data structures, we set
	// up the list of free physical pages. Once we've done so, all further
	// memory management will go through the page_* functions. In
	// particular, we can now map memory using boot_map_segment or page_insert
	page_init();

みたいなカンジで良いのかな。あとは page_init 手続きになります。とりあえずエントリ投入します。

ちなみに

免許更新は無事終了し、一つ用事を済ませて今、自宅の修繕立合中です。