{"id":1282,"date":"2012-02-19T06:13:11","date_gmt":"2012-02-18T12:13:11","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=1282"},"modified":"2012-05-31T15:18:40","modified_gmt":"2012-05-31T06:18:40","slug":"xv6%e3%82%bd%e3%83%bc%e3%82%b9%e3%82%b3%e3%83%bc%e3%83%89%e3%83%aa%e3%83%bc%e3%83%87%e3%82%a3%e3%83%b3%e3%82%b0-%e3%81%9d%e3%81%ae14","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/1282","title":{"rendered":"[xv6 #14] Chapter 1 &#8211; The first process &#8211; Code: Physical memory allocator"},"content":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e22\u301c23\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306f\u3001\u5272\u308a\u5f53\u3066\u53ef\u80fd\u306a\u7269\u7406\u30e1\u30e2\u30ea\u30da\u30fc\u30b8\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u3067\u3042\u308b\u3002<br \/>\n\u7a7a\u304d\u30da\u30fc\u30b8\u306e\u30ea\u30b9\u30c8\u306e\u8981\u7d20\u306frun\u69cb\u9020\u4f53\uff08struct run\uff09\u3067\u3042\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u305d\u306e\u69cb\u9020\u4f53\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306e\u30e1\u30e2\u30ea\u3092\u3069\u3053\u306b\u78ba\u4fdd\u3059\u308b\u304b\uff1f<br \/>\n\u7a7a\u304d\u30da\u30fc\u30b8\u305d\u308c\u81ea\u8eab\u306brun\u69cb\u9020\u4f53\u306f\u7f6e\u304b\u308c\u308b\u3002\uff08\u7f6e\u3051\u306a\u304f\u306a\u308b\u307e\u3067\uff09<br \/>\n\u7a7a\u304d\u30ea\u30b9\u30c8\u306f\u30b9\u30d4\u30f3\u30ed\u30c3\u30af\uff08spin lock\uff09\u3067\u4fdd\u8b77\u3055\u308c\u308b\u3002<br \/>\n\u7a7a\u304d\u30ea\u30b9\u30c8\u3068\u30ed\u30c3\u30af\u60c5\u5831\u306f\u3001\u305d\u306e\u69cb\u9020\u4f53\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u30ed\u30c3\u30af\u3067\u4fdd\u8b77\u3059\u308b\u3053\u3068\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u69cb\u9020\u4f53\u306e\u306a\u304b\u306b\u4e00\u7dd2\u306b\u307e\u3068\u3081\u3089\u308c\u3066\u3044\u308b\u3002<br \/>\n\u4eca\u306e\u3068\u3053\u308d\u306f\u3001\u305d\u306e\u30ed\u30c3\u30af\u6a5f\u69cb\u3068acquire\u95a2\u6570\u30fbrelease\u95a2\u6570\u306f\u7121\u8996\u3057\u306a\u3055\u3044\u3002<br \/>\n\u305d\u308c\u306b\u3064\u3044\u3066\u306f\u7b2c3\u7ae0\u3067\u8a73\u7d30\u3092\u8aac\u660e\u3059\u308b\u3002<br \/>\n\uff08\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u306fspinlock.h, spinlock.c\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u3002spinlock\u69cb\u9020\u4f53\u3084acquire\u95a2\u6570\u30fbrelease\u95a2\u6570\u306f\u305d\u3053\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u672c\u6587\u306b\u5f93\u3044\u3053\u3053\u3067\u306f\u307e\u3060\u305d\u306e\u30bd\u30fc\u30b9\u306f\u63b2\u8f09\u3057\u307e\u305b\u3093\u3002\uff09<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308brun\u69cb\u9020\u4f53\u3067\u3059\u3002\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">struct run {\r\n  struct run *next;\r\n};<\/pre>\n<p>main\u95a2\u6570\u306f\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u3092\u521d\u671f\u5316\u3059\u308b\u305f\u3081\u306bkinit\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nkinit\u306f\u3001\u307e\u305a\u3069\u308c\u3060\u3051\u306e\u7269\u7406\u30e1\u30e2\u30ea\u304c\u5229\u7528\u53ef\u80fd\u304b\u6c7a\u5b9a\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u3057\u304b\u3057\u3001\u305d\u308c\u306fx86\u3067\u306f\u96e3\u3057\u3044\u3002<br \/>\n\u305d\u306e\u4ee3\u308f\u308a\u3001\u30de\u30b7\u30f3\u306f\u5c11\u306a\u304f\u3068\u3082240MB\uff08PHYSTOP\uff09\u306e\u7269\u7406\u30e1\u30e2\u30ea\u3092\u6301\u3064\u3068\u4eee\u5b9a\u3057\u3001\u305d\u3057\u3066\u7a7a\u304d\u30e1\u30e2\u30ea\u306e\u6700\u521d\u306e\u30d7\u30fc\u30eb\u3068\u3057\u3066\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u7aef\u304b\u3089PHYSTOP\u306e\u9593\u306e\u5168\u3066\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3046\u3002<br \/>\nkinit\u95a2\u6570\u306f\u3001\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u7aef\u304b\u3089PHYSTOP\u306e\u9593\u306e\u30e1\u30e2\u30ea\u306e\u5168\u3066\u306e\u30da\u30fc\u30b8\u306e\u30a2\u30c9\u30ec\u30b9\u3068\u3068\u3082\u306bkfree\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nkfree\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u306b\u305d\u308c\u3089\u306e\u30da\u30fc\u30b8\u5168\u3066\u3092\u8ffd\u52a0\u3059\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u30e1\u30e2\u30ea\u7121\u3057\u3067\u958b\u59cb\u3059\u308b\u3002<br \/>\nkfree\u306f\u30a2\u30ed\u30b1\u30fc\u30bf\u306b\u3044\u304f\u3089\u304b\u7ba1\u7406\u3059\u3079\u304d\u3082\u306e\u3092\u4e0e\u3048\u308b\u3002<br \/>\n\uff08\u304b\u306a\u308a\u8a33\u304c\u3042\u3084\u3075\u3084\u3002\u539f\u6587: these calls to kfree give it some to manage.\uff09<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306ekinit, kfree\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Initialize free list of physical pages.\r\nvoid\r\nkinit(void)\r\n{\r\n  char *p;\r\n\r\n  initlock(&amp;kmem.lock, &quot;kmem&quot;);\r\n  p = (char*)PGROUNDUP((uint)newend);\r\n  for(; p + PGSIZE &lt;= (char*)p2v(PHYSTOP); p += PGSIZE)\r\n    kfree(p);\r\n}<\/pre>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/PAGEBREAK: 21\r\n\/\/ Free the page of physical memory pointed at by v,\r\n\/\/ which normally should have been returned by a\r\n\/\/ call to kalloc().  (The exception is when\r\n\/\/ initializing the allocator; see kinit above.)\r\nvoid\r\nkfree(char *v)\r\n{\r\n  struct run *r;\r\n\r\n  if((uint)v % PGSIZE || v &lt; end || v2p(v) &gt;= PHYSTOP)\r\n    panic(&quot;kfree&quot;);\r\n\r\n  \/\/ Fill with junk to catch dangling refs.\r\n  memset(v, 1, PGSIZE);\r\n\r\n  acquire(&amp;kmem.lock);\r\n  r = (struct run*)v;\r\n  r-&gt;next = kmem.freelist;\r\n  kmem.freelist = r;\r\n  release(&amp;kmem.lock);\r\n}<\/pre>\n<p>\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u3001\u4e0a\u4f4d\u30e1\u30e2\u30ea\u306b\u30de\u30c3\u30d7\u3055\u308c\u305f\u4eee\u60f3\u30a2\u30c9\u30ec\u30b9\u306b\u3088\u3063\u3066\u7269\u7406\u30da\u30fc\u30b8\u3092\u6307\u3059\u3002<br \/>\n\u6307\u3059\u306e\u306f\u7269\u7406\u30da\u30fc\u30b8\u3067\u3042\u3063\u3066\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3067\u306f\u306a\u3044\u3002<br \/>\n\u305d\u308c\u304c\u3001kinit\u304c\u3001PHYSTOP\uff08\u306e\u7269\u7406\u30a2\u30c9\u30ec\u30b9\uff09\u3092\u5909\u63db\u3059\u308b\u305f\u3081\u306bp2v(PHYSTOP)\u3092\u4f7f\u3046\u7406\u7531\u3067\u3042\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u305f\u307e\u306b\u3001\u30a2\u30c9\u30ec\u30b9\u95a2\u9023\u306e\u8a08\u7b97\u3092\u884c\u3046\u305f\u3081\u306b\u3001\u30a2\u30c9\u30ec\u30b9\u3092\u6574\u6570\u3068\u3057\u3066\u6271\u3046\u3002<br \/>\n\uff08\u4f8b\u3048\u3070\u3001kinit\u3067\u5168\u3066\u306e\u30da\u30fc\u30b8\u3092\u8d70\u67fb\u3057\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u305d\u3057\u3066\u3001\u305d\u306e\u4ed6\u306f\u30e1\u30e2\u30ea\u3092\u8aad\u307f\u66f8\u304d\u3059\u308b\u305f\u3081\u306b\u30a2\u30c9\u30ec\u30b9\u3092\u30dd\u30a4\u30f3\u30bf\u3068\u3057\u3066\u4f7f\u3046\u3002<br \/>\n\uff08\u30da\u30fc\u30b8\u3054\u3068\u306b\u4fdd\u6301\u3055\u308c\u305frun\u69cb\u9020\u4f53\u3092\u64cd\u4f5c\u3059\u308b\u90e8\u5206\uff09<br \/>\n\u3053\u306e\u30a2\u30c9\u30ec\u30b9\u306e2\u3064\u306e\u4f7f\u3044\u65b9\u304c\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u30b3\u30fc\u30c9\u304cC\u8a00\u8a9e\u306e\u30ad\u30e3\u30b9\u30c8\u3067\u3044\u3063\u3071\u3044\u3067\u3042\u308b\u3001\u4e3b\u306a\u7406\u7531\u3067\u3042\u308b\u3002<br \/>\n\u4ed6\u306e\u7406\u7531\u3068\u3057\u3066\u306f\u3001\u89e3\u653e\u3084\u5272\u308a\u5f53\u3066\u304c\u672c\u8cea\u7684\u306b\u30e1\u30e2\u30ea\u306e\u30bf\u30a4\u30d7\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u6319\u3052\u3089\u308c\u308b\u3002<\/p>\n<p>kfree\u95a2\u6570\u306f\u3001\u6e21\u3055\u308c\u305f\u30da\u30fc\u30b8\u306b\u5bfe\u5fdc\u3059\u308b\u30e1\u30e2\u30ea\u3092\u89e3\u653e\u3057\u30661\u3067\u57cb\u3081\u308b\u3053\u3068\u304b\u3089\u59cb\u307e\u308b\u3002<br \/>\n\u3053\u308c\u306f\u3001\u89e3\u653e\u3057\u305f\u3042\u3068\u30b3\u30fc\u30c9\u304c\u305d\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3046\u3068\u3001\u4ee5\u524d\u306e\u6b63\u3057\u3044\u5185\u5bb9\u306e\u4ee3\u308f\u308a\u306b\u30b4\u30df\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3057\u307e\u3046\u3001\u3068\u3044\u3046\u4e8b\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u3060\u308d\u3046\u3002<br \/>\n\u3046\u307e\u304f\u3044\u3051\u3070\u3001\u305d\u3093\u306a\u30b3\u30fc\u30c9\u306f\u901f\u3084\u304b\u306b\u4e2d\u65ad\u3059\u308b\u3060\u308d\u3046\u3002<br \/>\n\u6b21\u306b\u3001kfree\u95a2\u6570\u306f\u5909\u6570v\u3092run\u69cb\u9020\u4f53\u306e\u30dd\u30a4\u30f3\u30bf\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306e\u59cb\u307e\u308a\u3092r->next\u306b\u8a18\u9332\u3057\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306br\u3092\u4ee3\u5165\u3059\u308b\u3002<br \/>\nkalloc\u95a2\u6570\u306f\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u8981\u7d20\u3092\u8fd4\u3057\u3001\u305d\u308c\u3092\u30ea\u30b9\u30c8\u304b\u3089\u524a\u9664\u3059\u308b\u3002<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306ekalloc\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Allocate one 4096-byte page of physical memory.\r\n\/\/ Returns a pointer that the kernel can use.\r\n\/\/ Returns 0 if the memory cannot be allocated.\r\nchar*\r\nkalloc(void)\r\n{\r\n  struct run *r;\r\n\r\n  acquire(&amp;kmem.lock);\r\n  r = kmem.freelist;\r\n  if(r)\r\n    kmem.freelist = r-&gt;next;\r\n  release(&amp;kmem.lock);\r\n  return (char*)r;\r\n}<\/pre>\n<p>\u30ab\u30fc\u30cd\u30eb\u306e\u6700\u521d\u306e\u30da\u30fc\u30b8\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u3001setupkvm\u3068walkpgdir\u306f\u3001kalloc\u306e\u4ee3\u308f\u308a\u306benter_alloc\u3092\u4f7f\u3046\u3002<br \/>\n\u3053\u306e\u30e1\u30e2\u30ea\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u308f\u308a\u30921\u30da\u30fc\u30b8\u5206\u52d5\u304b\u3059\u3002<br \/>\nenter_alloc\u95a2\u6570\u306f\u3001\u30ab\u30fc\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u30bb\u30b0\u30e1\u30f3\u30c8\u306e\u7d42\u308f\u308a\u306e\u3059\u3050\u6b21\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3059end\u3068\u3044\u3046\u30b7\u30f3\u30dc\u30eb\u3092\u4f7f\u3046\u3002<br \/>\n\uff08end\u306f\u624b\u6253\u3061\u3058\u3083\u306a\u304f\u3066\u30ea\u30f3\u30ab\u304c\u8a2d\u5b9a\u3059\u308b\u3089\u3057\u3044\uff1f\uff09<br \/>\nPTE\u306f4096\u30d0\u30a4\u30c8\u5883\u754c\u3067\u533a\u5207\u3089\u308c\u305f\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3059\u3053\u3068\u3057\u304b\u3067\u304d\u306a\u3044\u3002<br \/>\n\u3067\u3001enter_alloc\u95a2\u6570\u306f\u3001\u305d\u306e\u5883\u754c\u3067\u533a\u5207\u3089\u308c\u305f\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3060\u3051\u3092\u5272\u308a\u5f53\u3066\u308b\u4e8b\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306bPGROUNDUP\u3092\u4f7f\u3046\u3002<br \/>\n\uff08mmu.h\u306b#define PGROUNDUP(sz)  (((sz)+PGSIZE-1) &#038; ~(PGSIZE-1))\u3068\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u3069\u3093\u306a\u30a2\u30c9\u30ec\u30b9\u3092\u6e21\u3057\u3066\u3082PGSIZE=4096\u30d0\u30a4\u30c8\u3067\u5206\u5272\u3055\u308c\u305f\u9818\u57df\u306e\u6700\u521d\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002\uff09<br \/>\nenter_alloc\u3067\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30e1\u30e2\u30ea\u306f\u305a\u3063\u3068\u89e3\u653e\u3055\u308c\u306a\u3044\u3002<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306eenter_alloc\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ A simple page allocator to get off the ground during entry\r\nchar *\r\nenter_alloc(void)\r\n{\r\n  if (newend == 0)\r\n    newend = end;\r\n\r\n  if ((uint) newend &gt;= KERNBASE + 0x400000)\r\n    panic(&quot;only first 4Mbyte are mapped during entry&quot;);\r\n  void *p = (void*)PGROUNDUP((uint)newend);\r\n  memset(p, 0, PGSIZE);\r\n  newend = newend + PGSIZE;\r\n  return p;\r\n}<\/pre>\n<h3>\u611f\u60f3<\/h3>\n<p>run\u69cb\u9020\u4f53\u304a\u3082\u3057\u308d\u3044\u3067\u3059\u306d\u3002<br \/>\n\u901a\u5e38\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\u3092\u4f7f\u3046\u3068\u304d\u306f\u3001\u6b21\u306e\u8981\u7d20\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u306b\u52a0\u3048\u4fdd\u6301\u3059\u308b\u30c7\u30fc\u30bf\u305d\u306e\u3082\u306e\uff08\u3082\u3057\u304f\u306f\u30c7\u30fc\u30bf\u3078\u306e\u30dd\u30a4\u30f3\u30bf\uff09\u3092\u6301\u3064\u308f\u3051\u3067\u3059\u3002<br \/>\n\u3057\u304b\u3057\u3001run\u69cb\u9020\u4f53\u306f\u3001\u6b21\u306e\u8981\u7d20\u3078\u306e\u30dd\u30a4\u30f3\u30bf\uff0832bit\uff09\u3092\u5b9f\u30e1\u30e2\u30ea\u4e0a\u3067\u5c02\u6709\u3059\u308b\u4e8b\u81ea\u4f53\u304c\u3059\u3067\u306b\u7528\u3092\u306a\u3057\u3066\u308b\u306e\u3067<br \/>\n\u30c7\u30fc\u30bf\u3092\u6301\u305f\u306a\u304f\u3066\u3044\u3044\u3063\u3066\u3053\u3068\u306a\u3093\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n<p>\u524d\u56de\u3061\u3089\u3063\u3068\u8a00\u53ca\u3055\u308c\u3066\u307e\u3057\u305f\u304c\u3001\u901a\u5e38\u4f7f\u3046\u30a2\u30ed\u30b1\u30fc\u30bf\u306fkalloc\u3001\u30d6\u30fc\u30c8\u6642\u306b\u4f7f\u3046\u3068\u308a\u3042\u3048\u305a\u306e\u30a2\u30ed\u30b1\u30fc\u30bf\u306fenter_alloc\u3063\u3066\u4e8b\u307f\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u901a\u5e38\u4f7f\u3046\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u7a7a\u304d\u30da\u30fc\u30b8\u3092\u6570\u73e0\u3064\u306a\u304e\u306b\u8a18\u9332\u3057\u305f\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\uff08\u7a7a\u304d\u30ea\u30b9\u30c8\uff09\u3092\u4f7f\u3063\u3066\u3001\u30e1\u30e2\u30ea\u306e\u5272\u5f53\u6642\u306b\u305d\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u304b\u3089\u5272\u308a\u51fa\u3057\u3001\u30e1\u30e2\u30ea\u306e\u958b\u653e\u6642\u306b\u305d\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u306b\u623b\u3059\u3068\u3044\u3046\u3053\u3068\u3092\u3084\u3063\u3066\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u4eca\u307e\u3067\u3001git clone git:\/\/pdos.csail.mit.edu\/xv6\/xv6.git \u3067\u30af\u30ed\u30fc\u30f3\u3057\u305f\u30ed\u30fc\u30ab\u30eb\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30bd\u30fc\u30b9\u3092\u305d\u306e\u307e\u307e\u8aad\u3093\u3067\u3066\u3001\u4ee5\u524d\u306b\u3082\u30bd\u30fc\u30b9\u3068\u30c6\u30ad\u30b9\u30c8\u3067\u4e0d\u6574\u5408\u306a\u90e8\u5206\u304c\u3042\u308b\u307f\u305f\u3044\u306a\u4e8b\u3092\u66f8\u3044\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u305d\u306e\u4e0d\u6574\u5408\u304c\u304b\u306a\u308a\u5927\u304d\u3044\u306e\u3067\u304a\u304b\u3057\u3044\u306a\u3068\u601d\u3044\u8abf\u3079\u305f\u3089\u3001\u30c6\u30ad\u30b9\u30c8\u3068\u4e00\u7dd2\u306b\u8aad\u307f\u9032\u3081\u308b\u3068\u304d\u306fxv6-rev6\u3068\u3044\u3046\u30bf\u30b0\u304c\u3064\u3044\u305f\u30b3\u30df\u30c3\u30c8\u3092\u4f7f\u308f\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u307f\u305f\u3044\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u5224\u660e\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u898b\u305f\u3089\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30b5\u30a4\u30c8 http:\/\/pdos.csail.mit.edu\/6.828\/2011\/xv6.html \u306b\u3082\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\n\u30af\u30ed\u30fc\u30f3\u3057\u3066\u304b\u3089git checkout -b xv6-rev6 xv6-rev6\u3068\u3059\u308b\u3068\u4f5c\u696d\u30b3\u30d4\u30fc\u304c\u30c6\u30ad\u30b9\u30c8\u6e96\u62e0\u7248\u306b\u306a\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u524d\u56de\u307e\u3067\u306b\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u65b9\u3092\u8aad\u307f\u66ff\u3048\u3066\u5bfe\u5fdc\u3057\u3066\u305f\u90e8\u5206\u304c\u3044\u304f\u3064\u304b\u3042\u3063\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u6c17\u304c\u5411\u3044\u305f\u3089\u4fee\u6b63\u3057\u307e\u3059\u304c\u3001\u7406\u89e3\u306e\u59a8\u3052\u306b\u306a\u308b\u307b\u3069\u306e\u5dee\u7570\u306f\u7121\u304b\u3063\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u305d\u306e\u307e\u307e\u3067\u4eca\u56de\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u6e96\u62e0\u7248\u306e\u30bd\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e22\u301c23\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306f\u3001\u5272\u308a\u5f53\u3066\u53ef\u80fd\u306a\u7269\u7406\u30e1\u30e2\u30ea\u30da\u30fc\u30b8\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u3067\u3042\u308b\u3002<br \/>\n\u7a7a\u304d\u30da\u30fc\u30b8\u306e\u30ea\u30b9\u30c8\u306e\u8981\u7d20\u306frun\u69cb\u9020\u4f53\uff08struct run\uff09\u3067\u3042\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u305d\u306e\u69cb\u9020\u4f53\u3092\u4fdd\u6301\u3059\u308b\u305f\u3081\u306e\u30e1\u30e2\u30ea\u3092\u3069\u3053\u306b\u78ba\u4fdd\u3059\u308b\u304b\uff1f<br \/>\n\u7a7a\u304d\u30da\u30fc\u30b8\u305d\u308c\u81ea\u8eab\u306brun\u69cb\u9020\u4f53\u306f\u7f6e\u304b\u308c\u308b\u3002\uff08\u7f6e\u3051\u306a\u304f\u306a\u308b\u307e\u3067\uff09<br \/>\n\u7a7a\u304d\u30ea\u30b9\u30c8\u306f\u30b9\u30d4\u30f3\u30ed\u30c3\u30af\uff08spin lock\uff09\u3067\u4fdd\u8b77\u3055\u308c\u308b\u3002<br \/>\n\u7a7a\u304d\u30ea\u30b9\u30c8\u3068\u30ed\u30c3\u30af\u60c5\u5831\u306f\u3001\u305d\u306e\u69cb\u9020\u4f53\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u30ed\u30c3\u30af\u3067\u4fdd\u8b77\u3059\u308b\u3053\u3068\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u69cb\u9020\u4f53\u306e\u306a\u304b\u306b\u4e00\u7dd2\u306b\u307e\u3068\u3081\u3089\u308c\u3066\u3044\u308b\u3002<br \/>\n\u4eca\u306e\u3068\u3053\u308d\u306f\u3001\u305d\u306e\u30ed\u30c3\u30af\u6a5f\u69cb\u3068acquire\u95a2\u6570\u30fbrelease\u95a2\u6570\u306f\u7121\u8996\u3057\u306a\u3055\u3044\u3002<br \/>\n\u305d\u308c\u306b\u3064\u3044\u3066\u306f\u7b2c3\u7ae0\u3067\u8a73\u7d30\u3092\u8aac\u660e\u3059\u308b\u3002<br \/>\n\uff08\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u306fspinlock.h, spinlock.c\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u3002spinlock\u69cb\u9020\u4f53\u3084acquire\u95a2\u6570\u30fbrelease\u95a2\u6570\u306f\u305d\u3053\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u672c\u6587\u306b\u5f93\u3044\u3053\u3053\u3067\u306f\u307e\u3060\u305d\u306e\u30bd\u30fc\u30b9\u306f\u63b2\u8f09\u3057\u307e\u305b\u3093\u3002\uff09<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308brun\u69cb\u9020\u4f53\u3067\u3059\u3002\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">struct run {\r\n  struct run *next;\r\n};<\/pre>\n<p>main\u95a2\u6570\u306f\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u3092\u521d\u671f\u5316\u3059\u308b\u305f\u3081\u306bkinit\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nkinit\u306f\u3001\u307e\u305a\u3069\u308c\u3060\u3051\u306e\u7269\u7406\u30e1\u30e2\u30ea\u304c\u5229\u7528\u53ef\u80fd\u304b\u6c7a\u5b9a\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u3057\u304b\u3057\u3001\u305d\u308c\u306fx86\u3067\u306f\u96e3\u3057\u3044\u3002<br \/>\n\u305d\u306e\u4ee3\u308f\u308a\u3001\u30de\u30b7\u30f3\u306f\u5c11\u306a\u304f\u3068\u3082240MB\uff08PHYSTOP\uff09\u306e\u7269\u7406\u30e1\u30e2\u30ea\u3092\u6301\u3064\u3068\u4eee\u5b9a\u3057\u3001\u305d\u3057\u3066\u7a7a\u304d\u30e1\u30e2\u30ea\u306e\u6700\u521d\u306e\u30d7\u30fc\u30eb\u3068\u3057\u3066\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u7aef\u304b\u3089PHYSTOP\u306e\u9593\u306e\u5168\u3066\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3046\u3002<br \/>\nkinit\u95a2\u6570\u306f\u3001\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u7aef\u304b\u3089PHYSTOP\u306e\u9593\u306e\u30e1\u30e2\u30ea\u306e\u5168\u3066\u306e\u30da\u30fc\u30b8\u306e\u30a2\u30c9\u30ec\u30b9\u3068\u3068\u3082\u306bkfree\u95a2\u6570\u3092\u547c\u3076\u3002<br \/>\nkfree\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u306b\u305d\u308c\u3089\u306e\u30da\u30fc\u30b8\u5168\u3066\u3092\u8ffd\u52a0\u3059\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u30e1\u30e2\u30ea\u7121\u3057\u3067\u958b\u59cb\u3059\u308b\u3002<br \/>\nkfree\u306f\u30a2\u30ed\u30b1\u30fc\u30bf\u306b\u3044\u304f\u3089\u304b\u7ba1\u7406\u3059\u3079\u304d\u3082\u306e\u3092\u4e0e\u3048\u308b\u3002<br \/>\n\uff08\u304b\u306a\u308a\u8a33\u304c\u3042\u3084\u3075\u3084\u3002\u539f\u6587: these calls to kfree give it some to manage.\uff09<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306ekinit, kfree\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Initialize free list of physical pages.\r\nvoid\r\nkinit(void)\r\n{\r\n  char *p;\r\n\r\n  initlock(&amp;kmem.lock, &quot;kmem&quot;);\r\n  p = (char*)PGROUNDUP((uint)newend);\r\n  for(; p + PGSIZE &lt;= (char*)p2v(PHYSTOP); p += PGSIZE)\r\n    kfree(p);\r\n}<\/pre>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/PAGEBREAK: 21\r\n\/\/ Free the page of physical memory pointed at by v,\r\n\/\/ which normally should have been returned by a\r\n\/\/ call to kalloc().  (The exception is when\r\n\/\/ initializing the allocator; see kinit above.)\r\nvoid\r\nkfree(char *v)\r\n{\r\n  struct run *r;\r\n\r\n  if((uint)v % PGSIZE || v &lt; end || v2p(v) &gt;= PHYSTOP)\r\n    panic(&quot;kfree&quot;);\r\n\r\n  \/\/ Fill with junk to catch dangling refs.\r\n  memset(v, 1, PGSIZE);\r\n\r\n  acquire(&amp;kmem.lock);\r\n  r = (struct run*)v;\r\n  r-&gt;next = kmem.freelist;\r\n  kmem.freelist = r;\r\n  release(&amp;kmem.lock);\r\n}<\/pre>\n<p>\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u3001\u4e0a\u4f4d\u30e1\u30e2\u30ea\u306b\u30de\u30c3\u30d7\u3055\u308c\u305f\u4eee\u60f3\u30a2\u30c9\u30ec\u30b9\u306b\u3088\u3063\u3066\u7269\u7406\u30da\u30fc\u30b8\u3092\u6307\u3059\u3002<br \/>\n\u6307\u3059\u306e\u306f\u7269\u7406\u30da\u30fc\u30b8\u3067\u3042\u3063\u3066\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3067\u306f\u306a\u3044\u3002<br \/>\n\u305d\u308c\u304c\u3001kinit\u304c\u3001PHYSTOP\uff08\u306e\u7269\u7406\u30a2\u30c9\u30ec\u30b9\uff09\u3092\u5909\u63db\u3059\u308b\u305f\u3081\u306bp2v(PHYSTOP)\u3092\u4f7f\u3046\u7406\u7531\u3067\u3042\u308b\u3002<br \/>\n\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u305f\u307e\u306b\u3001\u30a2\u30c9\u30ec\u30b9\u95a2\u9023\u306e\u8a08\u7b97\u3092\u884c\u3046\u305f\u3081\u306b\u3001\u30a2\u30c9\u30ec\u30b9\u3092\u6574\u6570\u3068\u3057\u3066\u6271\u3046\u3002<br \/>\n\uff08\u4f8b\u3048\u3070\u3001kinit\u3067\u5168\u3066\u306e\u30da\u30fc\u30b8\u3092\u8d70\u67fb\u3057\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u305d\u3057\u3066\u3001\u305d\u306e\u4ed6\u306f\u30e1\u30e2\u30ea\u3092\u8aad\u307f\u66f8\u304d\u3059\u308b\u305f\u3081\u306b\u30a2\u30c9\u30ec\u30b9\u3092\u30dd\u30a4\u30f3\u30bf\u3068\u3057\u3066\u4f7f\u3046\u3002<br \/>\n\uff08\u30da\u30fc\u30b8\u3054\u3068\u306b\u4fdd\u6301\u3055\u308c\u305frun\u69cb\u9020\u4f53\u3092\u64cd\u4f5c\u3059\u308b\u90e8\u5206\uff09<br \/>\n\u3053\u306e\u30a2\u30c9\u30ec\u30b9\u306e2\u3064\u306e\u4f7f\u3044\u65b9\u304c\u3001\u30a2\u30ed\u30b1\u30fc\u30bf\u306e\u30b3\u30fc\u30c9\u304cC\u8a00\u8a9e\u306e\u30ad\u30e3\u30b9\u30c8\u3067\u3044\u3063\u3071\u3044\u3067\u3042\u308b\u3001\u4e3b\u306a\u7406\u7531\u3067\u3042\u308b\u3002<br \/>\n\u4ed6\u306e\u7406\u7531\u3068\u3057\u3066\u306f\u3001\u89e3\u653e\u3084\u5272\u308a\u5f53\u3066\u304c\u672c\u8cea\u7684\u306b\u30e1\u30e2\u30ea\u306e\u30bf\u30a4\u30d7\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u6319\u3052\u3089\u308c\u308b\u3002<\/p>\n<p>kfree\u95a2\u6570\u306f\u3001\u6e21\u3055\u308c\u305f\u30da\u30fc\u30b8\u306b\u5bfe\u5fdc\u3059\u308b\u30e1\u30e2\u30ea\u3092\u89e3\u653e\u3057\u30661\u3067\u57cb\u3081\u308b\u3053\u3068\u304b\u3089\u59cb\u307e\u308b\u3002<br \/>\n\u3053\u308c\u306f\u3001\u89e3\u653e\u3057\u305f\u3042\u3068\u30b3\u30fc\u30c9\u304c\u305d\u306e\u30e1\u30e2\u30ea\u3092\u4f7f\u3046\u3068\u3001\u4ee5\u524d\u306e\u6b63\u3057\u3044\u5185\u5bb9\u306e\u4ee3\u308f\u308a\u306b\u30b4\u30df\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3057\u307e\u3046\u3001\u3068\u3044\u3046\u4e8b\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u3060\u308d\u3046\u3002<br \/>\n\u3046\u307e\u304f\u3044\u3051\u3070\u3001\u305d\u3093\u306a\u30b3\u30fc\u30c9\u306f\u901f\u3084\u304b\u306b\u4e2d\u65ad\u3059\u308b\u3060\u308d\u3046\u3002<br \/>\n\u6b21\u306b\u3001kfree\u95a2\u6570\u306f\u5909\u6570v\u3092run\u69cb\u9020\u4f53\u306e\u30dd\u30a4\u30f3\u30bf\u306b\u30ad\u30e3\u30b9\u30c8\u3057\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306e\u59cb\u307e\u308a\u3092r->next\u306b\u8a18\u9332\u3057\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306br\u3092\u4ee3\u5165\u3059\u308b\u3002<br \/>\nkalloc\u95a2\u6570\u306f\u3001\u7a7a\u304d\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u8981\u7d20\u3092\u8fd4\u3057\u3001\u305d\u308c\u3092\u30ea\u30b9\u30c8\u304b\u3089\u524a\u9664\u3059\u308b\u3002<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306ekalloc\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Allocate one 4096-byte page of physical memory.\r\n\/\/ Returns a pointer that the kernel can use.\r\n\/\/ Returns 0 if the memory cannot be allocated.\r\nchar*\r\nkalloc(void)\r\n{\r\n  struct run *r;\r\n\r\n  acquire(&amp;kmem.lock);\r\n  r = kmem.freelist;\r\n  if(r)\r\n    kmem.freelist = r-&gt;next;\r\n  release(&amp;kmem.lock);\r\n  return (char*)r;\r\n}<\/pre>\n<p>\u30ab\u30fc\u30cd\u30eb\u306e\u6700\u521d\u306e\u30da\u30fc\u30b8\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3059\u308b\u3068\u304d\u3001setupkvm\u3068walkpgdir\u306f\u3001kalloc\u306e\u4ee3\u308f\u308a\u306benter_alloc\u3092\u4f7f\u3046\u3002<br \/>\n\u3053\u306e\u30e1\u30e2\u30ea\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u30ab\u30fc\u30cd\u30eb\u306e\u7d42\u308f\u308a\u30921\u30da\u30fc\u30b8\u5206\u52d5\u304b\u3059\u3002<br \/>\nenter_alloc\u95a2\u6570\u306f\u3001\u30ab\u30fc\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u30bb\u30b0\u30e1\u30f3\u30c8\u306e\u7d42\u308f\u308a\u306e\u3059\u3050\u6b21\u306e\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3059end\u3068\u3044\u3046\u30b7\u30f3\u30dc\u30eb\u3092\u4f7f\u3046\u3002<br \/>\n\uff08end\u306f\u624b\u6253\u3061\u3058\u3083\u306a\u304f\u3066\u30ea\u30f3\u30ab\u304c\u8a2d\u5b9a\u3059\u308b\u3089\u3057\u3044\uff1f\uff09<br \/>\nPTE\u306f4096\u30d0\u30a4\u30c8\u5883\u754c\u3067\u533a\u5207\u3089\u308c\u305f\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u3059\u3053\u3068\u3057\u304b\u3067\u304d\u306a\u3044\u3002<br \/>\n\u3067\u3001enter_alloc\u95a2\u6570\u306f\u3001\u305d\u306e\u5883\u754c\u3067\u533a\u5207\u3089\u308c\u305f\u7269\u7406\u30a2\u30c9\u30ec\u30b9\u3060\u3051\u3092\u5272\u308a\u5f53\u3066\u308b\u4e8b\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306bPGROUNDUP\u3092\u4f7f\u3046\u3002<br \/>\n\uff08mmu.h\u306b#define PGROUNDUP(sz)  (((sz)+PGSIZE-1) &#038; ~(PGSIZE-1))\u3068\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u3069\u3093\u306a\u30a2\u30c9\u30ec\u30b9\u3092\u6e21\u3057\u3066\u3082PGSIZE=4096\u30d0\u30a4\u30c8\u3067\u5206\u5272\u3055\u308c\u305f\u9818\u57df\u306e\u6700\u521d\u306e\u30a2\u30c9\u30ec\u30b9\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059\u3002\uff09<br \/>\nenter_alloc\u3067\u5272\u308a\u5f53\u3066\u3089\u308c\u305f\u30e1\u30e2\u30ea\u306f\u305a\u3063\u3068\u89e3\u653e\u3055\u308c\u306a\u3044\u3002<br \/>\n\uff08\u4ee5\u4e0b\u306f\u3001kalloc.c\u306eenter_alloc\u95a2\u6570\uff09<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ A simple page allocator to get off the ground during entry\r\nchar *\r\nenter_alloc(void)\r\n{\r\n  if (newend == 0)\r\n    newend = end;\r\n\r\n  if ((uint) newend &gt;= KERNBASE + 0x400000)\r\n    panic(&quot;only first 4Mbyte are mapped during entry&quot;);\r\n  void *p = (void*)PGROUNDUP((uint)newend);\r\n  memset(p, 0, PGSIZE);\r\n  newend = newend + PGSIZE;\r\n  return p;\r\n}<\/pre>\n<h3>\u611f\u60f3<\/h3>\n<p>run\u69cb\u9020\u4f53\u304a\u3082\u3057\u308d\u3044\u3067\u3059\u306d\u3002<br \/>\n\u901a\u5e38\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\u3092\u4f7f\u3046\u3068\u304d\u306f\u3001\u6b21\u306e\u8981\u7d20\u3078\u306e\u30dd\u30a4\u30f3\u30bf\u306b\u52a0\u3048\u4fdd\u6301\u3059\u308b\u30c7\u30fc\u30bf\u305d\u306e\u3082\u306e\uff08\u3082\u3057\u304f\u306f\u30c7\u30fc\u30bf\u3078\u306e\u30dd\u30a4\u30f3\u30bf\uff09\u3092\u6301\u3064\u308f\u3051\u3067\u3059\u3002<br \/>\n\u3057\u304b\u3057\u3001run\u69cb\u9020\u4f53\u306f\u3001\u6b21\u306e\u8981\u7d20\u3078\u306e\u30dd\u30a4\u30f3\u30bf\uff0832bit\uff09\u3092\u5b9f\u30e1\u30e2\u30ea\u4e0a\u3067\u5c02\u6709\u3059\u308b\u4e8b\u81ea\u4f53\u304c\u3059\u3067\u306b\u7528\u3092\u306a\u3057\u3066\u308b\u306e\u3067<br \/>\n\u30c7\u30fc\u30bf\u3092\u6301\u305f\u306a\u304f\u3066\u3044\u3044\u3063\u3066\u3053\u3068\u306a\u3093\u3067\u3057\u3087\u3046\u306d\u3002<\/p>\n<p>\u524d\u56de\u3061\u3089\u3063\u3068\u8a00\u53ca\u3055\u308c\u3066\u307e\u3057\u305f\u304c\u3001\u901a\u5e38\u4f7f\u3046\u30a2\u30ed\u30b1\u30fc\u30bf\u306fkalloc\u3001\u30d6\u30fc\u30c8\u6642\u306b\u4f7f\u3046\u3068\u308a\u3042\u3048\u305a\u306e\u30a2\u30ed\u30b1\u30fc\u30bf\u306fenter_alloc\u3063\u3066\u4e8b\u307f\u305f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u901a\u5e38\u4f7f\u3046\u30a2\u30ed\u30b1\u30fc\u30bf\u306f\u7a7a\u304d\u30da\u30fc\u30b8\u3092\u6570\u73e0\u3064\u306a\u304e\u306b\u8a18\u9332\u3057\u305f\u30ea\u30f3\u30af\u30ea\u30b9\u30c8\uff08\u7a7a\u304d\u30ea\u30b9\u30c8\uff09\u3092\u4f7f\u3063\u3066\u3001\u30e1\u30e2\u30ea\u306e\u5272\u5f53\u6642\u306b\u305d\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u304b\u3089\u5272\u308a\u51fa\u3057\u3001\u30e1\u30e2\u30ea\u306e\u958b\u653e\u6642\u306b\u305d\u306e\u7a7a\u304d\u30ea\u30b9\u30c8\u306b\u623b\u3059\u3068\u3044\u3046\u3053\u3068\u3092\u3084\u3063\u3066\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u4eca\u307e\u3067\u3001git clone git:\/\/pdos.csail.mit.edu\/xv6\/xv6.git \u3067\u30af\u30ed\u30fc\u30f3\u3057\u305f\u30ed\u30fc\u30ab\u30eb\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30bd\u30fc\u30b9\u3092\u305d\u306e\u307e\u307e\u8aad\u3093\u3067\u3066\u3001\u4ee5\u524d\u306b\u3082\u30bd\u30fc\u30b9\u3068\u30c6\u30ad\u30b9\u30c8\u3067\u4e0d\u6574\u5408\u306a\u90e8\u5206\u304c\u3042\u308b\u307f\u305f\u3044\u306a\u4e8b\u3092\u66f8\u3044\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4eca\u56de\u305d\u306e\u4e0d\u6574\u5408\u304c\u304b\u306a\u308a\u5927\u304d\u3044\u306e\u3067\u304a\u304b\u3057\u3044\u306a\u3068\u601d\u3044\u8abf\u3079\u305f\u3089\u3001\u30c6\u30ad\u30b9\u30c8\u3068\u4e00\u7dd2\u306b\u8aad\u307f\u9032\u3081\u308b\u3068\u304d\u306fxv6-rev6\u3068\u3044\u3046\u30bf\u30b0\u304c\u3064\u3044\u305f\u30b3\u30df\u30c3\u30c8\u3092\u4f7f\u308f\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u307f\u305f\u3044\u3060\u3068\u3044\u3046\u3053\u3068\u304c\u5224\u660e\u3057\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u898b\u305f\u3089\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u30b5\u30a4\u30c8 http:\/\/pdos.csail.mit.edu\/6.828\/2011\/xv6.html \u306b\u3082\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\n\u30af\u30ed\u30fc\u30f3\u3057\u3066\u304b\u3089git checkout -b xv6-rev6 xv6-rev6\u3068\u3059\u308b\u3068\u4f5c\u696d\u30b3\u30d4\u30fc\u304c\u30c6\u30ad\u30b9\u30c8\u6e96\u62e0\u7248\u306b\u306a\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u524d\u56de\u307e\u3067\u306b\u3001\u30c6\u30ad\u30b9\u30c8\u306e\u65b9\u3092\u8aad\u307f\u66ff\u3048\u3066\u5bfe\u5fdc\u3057\u3066\u305f\u90e8\u5206\u304c\u3044\u304f\u3064\u304b\u3042\u3063\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u6c17\u304c\u5411\u3044\u305f\u3089\u4fee\u6b63\u3057\u307e\u3059\u304c\u3001\u7406\u89e3\u306e\u59a8\u3052\u306b\u306a\u308b\u307b\u3069\u306e\u5dee\u7570\u306f\u7121\u304b\u3063\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3068\u308a\u3042\u3048\u305a\u305d\u306e\u307e\u307e\u3067\u4eca\u56de\u304b\u3089\u30c6\u30ad\u30b9\u30c8\u6e96\u62e0\u7248\u306e\u30bd\u30fc\u30b9\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[405],"class_list":["post-1282","post","type-post","status-publish","format-standard","hentry","category-tech","tag-xv6"],"_links":{"self":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/1282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/comments?post=1282"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/1282\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=1282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=1282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=1282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}