{"id":1433,"date":"2012-03-12T16:59:26","date_gmt":"2012-03-11T22:59:26","guid":{"rendered":"http:\/\/peta.okechan.net\/blog\/?p=1433"},"modified":"2012-03-14T11:21:42","modified_gmt":"2012-03-14T02:21:42","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%ae37","status":"publish","type":"post","link":"https:\/\/peta.okechan.net\/blog\/archives\/1433","title":{"rendered":"[xv6 #37] Chapter 3 &#8211; Locking &#8211; Code: Using locks"},"content":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e46\u301c47\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>xv6\u306f\u3001\u7af6\u5408\u72b6\u614b\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u30ed\u30c3\u30af\u3092\u5229\u7528\u3057\u3066\u614e\u91cd\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3055\u308c\u3066\u3044\u308b\u3002<br \/>\n\u5358\u7d14\u306a\u4f8b\u306f\u3001IDE\u30c9\u30e9\u30a4\u30d0\u3067\u3042\u308b\u3002<br \/>\n\u3053\u306e\u7ae0\u306e\u306f\u3058\u3081\u3067\u8a00\u53ca\u3057\u305f\u3088\u3046\u306b\u3001iderw\u95a2\u6570\u306f\u3001\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ad\u30e5\u30fc\u3092\u6301\u3061\u3001\u30d7\u30ed\u30bb\u30c3\u30b5\u306f\u540c\u6642\u306b\u305d\u306e\u30ea\u30b9\u30c8\u3078\u65b0\u3057\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u3060\u308d\u3046\u3002\uff08iderw\u95a2\u6570\u306eDOC:insert\u2212queue\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u3053\u306e\u30ea\u30b9\u30c8\u3068\u305d\u306e\u4ed6\u306e\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306b\u3001iderw\u306fidelock\u3092\u7372\u5f97\u3057\uff08acquire\u3057\uff09\u3001\u95a2\u6570\u306e\u7d42\u308f\u308a\u3067\u305d\u308c\u3092\u89e3\u653e\u3059\u308b\u3002<br \/>\n\u30ad\u30e5\u30fc\u306e\u64cd\u4f5c\u306e\u5f8c\u306bacquire\u306e\u547c\u3073\u51fa\u3057\u3092\u79fb\u52d5\u3059\u308b\u4e8b\u306b\u3088\u3063\u3066\u3001\u3053\u306e\u7ae0\u306e\u306f\u3058\u3081\u306e\u307b\u3046\u3067\u898b\u305f\u3088\u3046\u306a\u7af6\u5408\u72b6\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u65b9\u6cd5\u3092\u8abf\u3079\u308b\u3068\u3044\u3046\u7df4\u7fd2\u554f\u984c1\u304c\u3042\u308b\u3002<br \/>\n\u305d\u306e\u7df4\u7fd2\u554f\u984c\u306f\u8a66\u3059\u4fa1\u5024\u304c\u3042\u308b\u3002<br \/>\n\u306a\u305c\u306a\u3089\u3001\u7af6\u5408\u3092\u5f15\u304d\u8d77\u3053\u3059\u3053\u3068\u306f\u7c21\u5358\u3067\u306f\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u30cf\u30c3\u30ad\u30ea\u3059\u308b\u304b\u3089\u3067\u3042\u308b\u3002<br \/>\n\u3064\u307e\u308a\u305d\u308c\u306f\u3001\u7af6\u5408\u72b6\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u30d0\u30b0\u3092\u63a2\u3059\u306e\u306f\u96e3\u3057\u3044\u3068\u3044\u3046\u3053\u3068\u3092\u610f\u5473\u3059\u308b\u3002<br \/>\nxv6\u304c\u3001\u305d\u3093\u306a\u3044\u304f\u3064\u304b\u306e\u7af6\u5408\u3092\u6301\u3064\u53ef\u80fd\u6027\u306f\u306a\u304f\u3082\u306a\u3044\u3002<\/p>\n<p>ide.c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Simple PIO-based (non-DMA) IDE driver code.\n\n#include &quot;types.h&quot;\n#include &quot;defs.h&quot;\n#include &quot;param.h&quot;\n#include &quot;memlayout.h&quot;\n#include &quot;mmu.h&quot;\n#include &quot;proc.h&quot;\n#include &quot;x86.h&quot;\n#include &quot;traps.h&quot;\n#include &quot;spinlock.h&quot;\n#include &quot;buf.h&quot;\n\n#define IDE_BSY       0x80\n#define IDE_DRDY      0x40\n#define IDE_DF        0x20\n#define IDE_ERR       0x01\n\n#define IDE_CMD_READ  0x20\n#define IDE_CMD_WRITE 0x30\n\n\/\/ idequeue points to the buf now being read\/written to the disk.\n\/\/ idequeue-&gt;qnext points to the next buf to be processed.\n\/\/ You must hold idelock while manipulating queue.\n\nstatic struct spinlock idelock;\nstatic struct buf *idequeue;\n\nstatic int havedisk1;\nstatic void idestart(struct buf*);\n\n\/\/ Wait for IDE disk to become ready.\nstatic int\nidewait(int checkerr)\n{\n  int r;\n\n  while(((r = inb(0x1f7)) &amp; (IDE_BSY|IDE_DRDY)) != IDE_DRDY) \n    ;\n  if(checkerr &amp;&amp; (r &amp; (IDE_DF|IDE_ERR)) != 0)\n    return -1;\n  return 0;\n}\n\nvoid\nideinit(void)\n{\n  int i;\n\n  initlock(&amp;idelock, &quot;ide&quot;);\n  picenable(IRQ_IDE);\n  ioapicenable(IRQ_IDE, ncpu - 1);\n  idewait(0);\n  \n  \/\/ Check if disk 1 is present\n  outb(0x1f6, 0xe0 | (1&lt;&lt;4));\n  for(i=0; i&lt;1000; i++){\n    if(inb(0x1f7) != 0){\n      havedisk1 = 1;\n      break;\n    }\n  }\n  \n  \/\/ Switch back to disk 0.\n  outb(0x1f6, 0xe0 | (0&lt;&lt;4));\n}\n\n\/\/ Start the request for b.  Caller must hold idelock.\nstatic void\nidestart(struct buf *b)\n{\n  if(b == 0)\n    panic(&quot;idestart&quot;);\n\n  idewait(0);\n  outb(0x3f6, 0);  \/\/ generate interrupt\n  outb(0x1f2, 1);  \/\/ number of sectors\n  outb(0x1f3, b-&gt;sector &amp; 0xff);\n  outb(0x1f4, (b-&gt;sector &gt;&gt; 8) &amp; 0xff);\n  outb(0x1f5, (b-&gt;sector &gt;&gt; 16) &amp; 0xff);\n  outb(0x1f6, 0xe0 | ((b-&gt;dev&amp;1)&lt;&lt;4) | ((b-&gt;sector&gt;&gt;24)&amp;0x0f));\n  if(b-&gt;flags &amp; B_DIRTY){\n    outb(0x1f7, IDE_CMD_WRITE);\n    outsl(0x1f0, b-&gt;data, 512\/4);\n  } else {\n    outb(0x1f7, IDE_CMD_READ);\n  }\n}\n\n\/\/ Interrupt handler.\nvoid\nideintr(void)\n{\n  struct buf *b;\n\n  \/\/ Take first buffer off queue.\n  acquire(&amp;idelock);\n  if((b = idequeue) == 0){\n    release(&amp;idelock);\n    \/\/ cprintf(&quot;spurious IDE interrupt\\n&quot;);\n    return;\n  }\n  idequeue = b-&gt;qnext;\n\n  \/\/ Read data if needed.\n  if(!(b-&gt;flags &amp; B_DIRTY) &amp;&amp; idewait(1) &gt;= 0)\n    insl(0x1f0, b-&gt;data, 512\/4);\n  \n  \/\/ Wake process waiting for this buf.\n  b-&gt;flags |= B_VALID;\n  b-&gt;flags &amp;= ~B_DIRTY;\n  wakeup(b);\n  \n  \/\/ Start disk on next buf in queue.\n  if(idequeue != 0)\n    idestart(idequeue);\n\n  release(&amp;idelock);\n}\n\n\/\/PAGEBREAK!\n\/\/ Sync buf with disk. \n\/\/ If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.\n\/\/ Else if B_VALID is not set, read buf from disk, set B_VALID.\nvoid\niderw(struct buf *b)\n{\n  struct buf **pp;\n\n  if(!(b-&gt;flags &amp; B_BUSY))\n    panic(&quot;iderw: buf not busy&quot;);\n  if((b-&gt;flags &amp; (B_VALID|B_DIRTY)) == B_VALID)\n    panic(&quot;iderw: nothing to do&quot;);\n  if(b-&gt;dev != 0 &amp;&amp; !havedisk1)\n    panic(&quot;iderw: ide disk 1 not present&quot;);\n\n  acquire(&amp;idelock);  \/\/ DOC:acquire-lock\n\n  \/\/ Append b to idequeue.\n  b-&gt;qnext = 0;\n  for(pp=&amp;idequeue; *pp; pp=&amp;(*pp)-&gt;qnext)  \/\/ DOC:insert-queue\n    ;\n  *pp = b;\n  \n  \/\/ Start disk if necessary.\n  if(idequeue == b)\n    idestart(b);\n  \n  \/\/ Wait for request to finish.\n  \/\/ Assuming will not sleep too long: ignore proc-&gt;killed.\n  while((b-&gt;flags &amp; (B_VALID|B_DIRTY)) != B_VALID){\n    sleep(b, &amp;idelock);\n  }\n\n  release(&amp;idelock);\n}<\/pre>\n<p>\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3053\u3068\u306e\u96e3\u3057\u3044\u90e8\u5206\u306f\u3001\u3069\u3046\u3084\u3063\u3066\u591a\u304f\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u304b\u3001\u305d\u3057\u3066\u3069\u306e\u30ed\u30c3\u30af\u304c\u3069\u306e\u30c7\u30fc\u30bf\u3068\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u306e\u304b\u6c7a\u3081\u308b\u3053\u3068\u3067\u3042\u308b\u3002<br \/>\n\u305d\u3053\u306b\u306f\u3044\u304f\u3064\u304b\u306e\u57fa\u672c\u7684\u306a\u539f\u5247\u304c\u3042\u308b\u3002<br \/>\n\u6700\u521d\u306b\u3001\u4ed6\u306eCPU\u304c\u8aad\u307f\u66f8\u304d\u3067\u304d\u308b\u3088\u3046\u306a\u5909\u6570\u306f\u3044\u3064\u3067\u3082\u3001\u540c\u6642\u306b\u3042\u308bCPU\u304b\u3089\u66f8\u304d\u8fbc\u307e\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3002<br \/>\n\u30ed\u30c3\u30af\u306f\u3001\u305d\u306e2\u3064\u306e\u64cd\u4f5c\u304c\u30aa\u30fc\u30d0\u30fc\u30e9\u30c3\u30d7\u3057\u306a\u3044\u3088\u3046\u306b\u5c0e\u304f\u3079\u304d\u3067\u3042\u308b\u3002<br \/>\n\u6b21\u306b\u3001\u30ed\u30c3\u30af\u306f\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u5fd8\u308c\u308b\u306a\u3002<br \/>\n\u3042\u308b\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u304c\u8907\u6570\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u307e\u305f\u304c\u308b\u5834\u5408\u3001\u5178\u578b\u7684\u306b\u306f\u3001\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u3053\u3068\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u4e00\u3064\u306e\u30ed\u30c3\u30af\u306b\u3088\u3063\u3066\u3001\u305d\u306e\u5168\u3066\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306f\u4fdd\u8b77\u3055\u308c\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30eb\u30fc\u30eb\u306f\u3001\u30ed\u30c3\u30af\u304c\u5fc5\u8981\u306a\u3068\u304d\u306e\u8a71\u3067\u3042\u308a\u3001\u30ed\u30c3\u30af\u304c\u4e0d\u5fc5\u8981\u306a\u5834\u5408\u306b\u3064\u3044\u3066\u306f\u4f55\u3082\u8a9e\u3063\u3066\u306f\u3044\u306a\u3044\u3002<br \/>\n\u305d\u3057\u3066\u3001\u52b9\u7387\u4e0a\u91cd\u8981\u306a\u70b9\u3067\u3042\u308b\u304c\u3001\u30ed\u30c3\u30af\u306f\u4e26\u5217\u6027\u3092\u640d\u306a\u3046\u306e\u3067\u3001\u30ed\u30c3\u30af\u306f\u4f7f\u3044\u904e\u304e\u306a\u3044\u3088\u3046\u306b\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u52b9\u7387\u304c\u91cd\u8981\u3067\u306a\u3044\u5834\u5408\u3001\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u306e\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3068\u3057\u3066\u4f7f\u3048\u3070\u3001\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u306f\u6c17\u306b\u3059\u308b\u5fc5\u8981\u306f\u306a\u304f\u306a\u308b\u3002<br \/>\n\u30ab\u30fc\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306a\u3089\u3001\u30ab\u30fc\u30cd\u30eb\u306b\u5165\u308b\u3068\u304d\u306b\u7372\u5f97\u3055\u308c\u3001\u30ab\u30fc\u30cd\u30eb\u3092\u51fa\u308b\u3068\u304d\u306b\u89e3\u653e\u3055\u308c\u308b\u3088\u3046\u306a\u30ed\u30c3\u30af\u304c\u4e00\u3064\u3042\u308c\u3070\u3044\u3044\u3002<br \/>\n\u591a\u304f\u306e\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u7528\u306eOS\u306e\u306f\u3001\u3068\u304d\u3069\u304d\u30b8\u30e3\u30a4\u30a2\u30f3\u30c8\u30ed\u30c3\u30af\uff08giant kernel lock\uff09\u3068\u547c\u3070\u308c\u308b\u3053\u306e\u3084\u308a\u65b9\u3092\u7528\u3044\u3066\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5b9f\u884c\u51fa\u6765\u308b\u3088\u3046\u79fb\u884c\u3057\u3066\u304d\u305f\u3002<br \/>\n\u3057\u304b\u3057\u3053\u306e\u65b9\u6cd5\u306f\u3001\u672c\u7269\u306e\u540c\u6642\u5b9f\u884c\u6027\u3092\u72a0\u7272\u306b\u3059\u308b\u3002<br \/>\n\u4e00\u5ea6\u306b\u3072\u3068\u3064\u306eCPU\u3060\u3051\u304c\u3001\u30ab\u30fc\u30cd\u30eb\u3067\u5b9f\u884c\u51fa\u6765\u308b\u306e\u307f\u3067\u3042\u308b\u3002<br \/>\n\u30ab\u30fc\u30cd\u30eb\u304c\u4f55\u304b\u91cd\u3044\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001\u3088\u308a\u7d30\u304b\u3044\u7c92\u5ea6\u306e\u30ed\u30c3\u30af\u306e\u5927\u304d\u306a\u30bb\u30c3\u30c8\u3092\u6271\u3046\u306e\u304c\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u3042\u308b\u3002<br \/>\n\u3082\u3057\u305d\u3046\u306a\u3089\u3001\u30ab\u30fc\u30cd\u30eb\u306f\u8907\u6570\u306eCPU\u4e0a\u3067\u540c\u6642\u306b\u5b9f\u884c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u7a76\u6975\u7684\u306b\u306f\u3001\u30ed\u30c3\u30af\u7c92\u5ea6\u306e\u9078\u629e\u306f\u3001\u4e26\u5217\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3051\u308b\u8ab2\u984c\u3067\u3042\u308b\u3002<br \/>\nxv6\u306f\u3001\u5c11\u306a\u304f\u7c92\u5ea6\u304c\u7c97\u3044\u30c7\u30fc\u30bf\u69cb\u9020\u7279\u6709\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3002<br \/>\n\u4f8b\u3048\u3070xv6\u306f\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u3068\u305d\u306e\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306b\u4e00\u3064\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3002<br \/>\n\uff08\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u306b\u3064\u3044\u3066\u306f\u7b2c4\u7ae0\u3067\u8aac\u660e\u3059\u308b\u3002\uff09<br \/>\n\u3088\u308a\u7d30\u304b\u3044\u7c92\u5ea6\u306e\u65b9\u6cd5\u3067\u306f\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u306e\u500b\u5225\u306e\u30a8\u30f3\u30c8\u30ea\u4e0a\u3067\u52d5\u3044\u3066\u3044\u308b\u30b9\u30ec\u30c3\u30c9\u304c\u3001\u4e26\u884c\u3057\u3066\u7d9a\u884c\u51fa\u6765\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u3072\u3068\u3064\u306e\u30a8\u30f3\u30c8\u30ea\u6bce\u306b\u30ed\u30c3\u30af\u3092\u6301\u3064\u3060\u308d\u3046\u3002<br \/>\n\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u5168\u4f53\u306b\u6e21\u308b\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u6301\u3064\u64cd\u4f5c\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u30ed\u30c3\u30af\u3092\u6301\u3061\u51fa\u3055\u306a\u304d\u3083\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u8907\u96d1\u306b\u306a\u308b\u3002<br \/>\nxv6\u306e\u4f8b\u304c\u3001\u30ed\u30c3\u30af\u306e\u4f7f\u3044\u65b9\u3092\u4f1d\u3048\u308b\u624b\u52a9\u3051\u306b\u306a\u308b\u3053\u3068\u3092\u9858\u3046\u3002<\/p>\n<h3>\u611f\u60f3<\/h3>\n<p>\u304a\u3082\u3080\u308d\u306b\u7df4\u7fd2\u554f\u984c1\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3057\u8a66\u3059\u306a\u3089\u3001\u6c7a\u307e\u3063\u305f\u30d1\u30bf\u30fc\u30f3\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u3001\u305d\u308c\u3092\u8907\u6570\u540c\u6642\u5b9f\u884c\u3059\u308b\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3082\u3057\u7af6\u5408\u72b6\u614b\u304c\u767a\u751f\u3057\u305f\u3089\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u306b\u6b20\u843d\u304c\u8d77\u304d\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\n\u305f\u3060\u3001\u78ba\u7387\u7684\u306b\u306a\u304b\u306a\u308a\u4f4e\u305d\u3046\u306a\u306e\u3067\u3069\u306e\u304f\u3089\u3044\u3084\u3063\u305f\u3089\u89b3\u6e2c\u53ef\u80fd\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u3002<br \/>\niderw\u3067\u306f\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u307e\u3067\u8fbf\u3063\u3066\u3001\u3059\u304b\u3055\u305a\u305d\u306e\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u306b\u65b0\u3057\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u307e\u3059\uff08*pp = b;\u306e\u884c\uff09\u304c\u3001\u3042\u308bCPU\u306b\u304a\u3051\u308b\u305d\u306e\u884c\u306e\u51e6\u7406\u304c\u3001\u4ed6\u306eCPU\u304c\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u307e\u3067\u8fbf\u3063\u305f\u76f4\u5f8c\u304b\u3064\u8ffd\u52a0\u306e\u76f4\u524d\u306b\u884c\u308f\u308c\u305f\u3089\u7af6\u5408\u72b6\u614b\u306b\u306a\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\n\u591a\u5206panic\u3057\u305f\u308a\u3068\u304b\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u3057\u305f\u308a\u3068\u304b\u306b\u306f\u306a\u3089\u306a\u3044\u306f\u305a\u306a\u306e\u3067\u3001\u8868\u9762\u4e0a\u306f\u4f55\u3082\u554f\u984c\u306a\u3044\u3088\u3046\u306b\u898b\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30de\u754c\u9688\u306e\u7b11\u3044\u8a71\u3068\u3057\u3066\u3001\u300c\u8b0e\u306eprint\u6587\u306b\u3001\u3053\u306e\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u305f\u3089\u4f55\u6545\u304b\u4ed6\u306e\u7b87\u6240\u3067\u554f\u984c\u304c\u8d77\u304d\u308b\u306e\u3067\u6ce8\u610f\u3002\u306a\u3093\u3066\u3044\u3046\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u305f\u300d\u306a\u3093\u3066\u306e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3053\u307e\u3067\u5206\u304b\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3001\uff08\u305d\u306e\u539f\u56e0\u3092\u653e\u7f6e\u3057\u3066\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u7570\u5e38\u3067\u3059\u304c\uff09\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u4ed5\u7d44\u307f\u7684\u306b\u306f\u7279\u306b\u4e0d\u601d\u8b70\u3067\u3082\u306a\u3093\u3067\u3082\u306a\u3044\u3067\u3059\u306d\u3002<br \/>\n\u305d\u3046\u3044\u3046\u5834\u5408\u30e1\u30e2\u30ea\u7ba1\u7406\u306b\u554f\u984c\u304c\u3042\u308b\u53ef\u80fd\u6027\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u9055\u3044\u306b\u3088\u3063\u3066\u6f5c\u5728\u7684\u306a\u7af6\u5408\u72b6\u614b\u304c\u8868\u9762\u5316\u3059\u308b\u304b\u3057\u306a\u3044\u304b\u306e\u5dee\u304c\u51fa\u3066\u308b\u3060\u3051\u3063\u3066\u306e\u304c\u3057\u3063\u304f\u308a\u6765\u307e\u3059\u3002<\/p>\n<p>\u4e26\u5217\u6027\u3092\u4e0a\u3052\u308b\u306b\u306f\u3001\u30ed\u30c3\u30af\u7c92\u5ea6\u3092\u7d30\u304b\u304f\u3057\u3066\u6570\u3092\u5897\u3084\u3059\u306e\u304c\u6709\u52b9\u3068\u3082\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\n\u4f3c\u305f\u3088\u3046\u306a\u4f8b\u3068\u3057\u3066\u3001DB\u306e\u30c6\u30fc\u30d6\u30eb\u30ed\u30c3\u30af\u3068\u884c\u30ed\u30c3\u30af\u306e\u4e26\u5217\u6027\u306b\u3064\u3044\u3066\u306e\u8a71\u304c\u3042\u308a\u307e\u3059\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30c6\u30ad\u30b9\u30c8\u306e46\u301c47\u30da\u30fc\u30b8<\/p>\n<h3>\u672c\u6587<\/h3>\n<p>xv6\u306f\u3001\u7af6\u5408\u72b6\u614b\u3092\u907f\u3051\u308b\u305f\u3081\u306b\u30ed\u30c3\u30af\u3092\u5229\u7528\u3057\u3066\u614e\u91cd\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3055\u308c\u3066\u3044\u308b\u3002<br \/>\n\u5358\u7d14\u306a\u4f8b\u306f\u3001IDE\u30c9\u30e9\u30a4\u30d0\u3067\u3042\u308b\u3002<br \/>\n\u3053\u306e\u7ae0\u306e\u306f\u3058\u3081\u3067\u8a00\u53ca\u3057\u305f\u3088\u3046\u306b\u3001iderw\u95a2\u6570\u306f\u3001\u30c7\u30a3\u30b9\u30af\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30ad\u30e5\u30fc\u3092\u6301\u3061\u3001\u30d7\u30ed\u30bb\u30c3\u30b5\u306f\u540c\u6642\u306b\u305d\u306e\u30ea\u30b9\u30c8\u3078\u65b0\u3057\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3059\u308b\u3060\u308d\u3046\u3002\uff08iderw\u95a2\u6570\u306eDOC:insert\u2212queue\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u308b\u90e8\u5206\uff09<br \/>\n\u3053\u306e\u30ea\u30b9\u30c8\u3068\u305d\u306e\u4ed6\u306e\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306b\u3001iderw\u306fidelock\u3092\u7372\u5f97\u3057\uff08acquire\u3057\uff09\u3001\u95a2\u6570\u306e\u7d42\u308f\u308a\u3067\u305d\u308c\u3092\u89e3\u653e\u3059\u308b\u3002<br \/>\n\u30ad\u30e5\u30fc\u306e\u64cd\u4f5c\u306e\u5f8c\u306bacquire\u306e\u547c\u3073\u51fa\u3057\u3092\u79fb\u52d5\u3059\u308b\u4e8b\u306b\u3088\u3063\u3066\u3001\u3053\u306e\u7ae0\u306e\u306f\u3058\u3081\u306e\u307b\u3046\u3067\u898b\u305f\u3088\u3046\u306a\u7af6\u5408\u72b6\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u65b9\u6cd5\u3092\u8abf\u3079\u308b\u3068\u3044\u3046\u7df4\u7fd2\u554f\u984c1\u304c\u3042\u308b\u3002<br \/>\n\u305d\u306e\u7df4\u7fd2\u554f\u984c\u306f\u8a66\u3059\u4fa1\u5024\u304c\u3042\u308b\u3002<br \/>\n\u306a\u305c\u306a\u3089\u3001\u7af6\u5408\u3092\u5f15\u304d\u8d77\u3053\u3059\u3053\u3068\u306f\u7c21\u5358\u3067\u306f\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u304c\u30cf\u30c3\u30ad\u30ea\u3059\u308b\u304b\u3089\u3067\u3042\u308b\u3002<br \/>\n\u3064\u307e\u308a\u305d\u308c\u306f\u3001\u7af6\u5408\u72b6\u614b\u3092\u5f15\u304d\u8d77\u3053\u3059\u30d0\u30b0\u3092\u63a2\u3059\u306e\u306f\u96e3\u3057\u3044\u3068\u3044\u3046\u3053\u3068\u3092\u610f\u5473\u3059\u308b\u3002<br \/>\nxv6\u304c\u3001\u305d\u3093\u306a\u3044\u304f\u3064\u304b\u306e\u7af6\u5408\u3092\u6301\u3064\u53ef\u80fd\u6027\u306f\u306a\u304f\u3082\u306a\u3044\u3002<\/p>\n<p>ide.c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\/\/ Simple PIO-based (non-DMA) IDE driver code.\n\n#include &quot;types.h&quot;\n#include &quot;defs.h&quot;\n#include &quot;param.h&quot;\n#include &quot;memlayout.h&quot;\n#include &quot;mmu.h&quot;\n#include &quot;proc.h&quot;\n#include &quot;x86.h&quot;\n#include &quot;traps.h&quot;\n#include &quot;spinlock.h&quot;\n#include &quot;buf.h&quot;\n\n#define IDE_BSY       0x80\n#define IDE_DRDY      0x40\n#define IDE_DF        0x20\n#define IDE_ERR       0x01\n\n#define IDE_CMD_READ  0x20\n#define IDE_CMD_WRITE 0x30\n\n\/\/ idequeue points to the buf now being read\/written to the disk.\n\/\/ idequeue-&gt;qnext points to the next buf to be processed.\n\/\/ You must hold idelock while manipulating queue.\n\nstatic struct spinlock idelock;\nstatic struct buf *idequeue;\n\nstatic int havedisk1;\nstatic void idestart(struct buf*);\n\n\/\/ Wait for IDE disk to become ready.\nstatic int\nidewait(int checkerr)\n{\n  int r;\n\n  while(((r = inb(0x1f7)) &amp; (IDE_BSY|IDE_DRDY)) != IDE_DRDY) \n    ;\n  if(checkerr &amp;&amp; (r &amp; (IDE_DF|IDE_ERR)) != 0)\n    return -1;\n  return 0;\n}\n\nvoid\nideinit(void)\n{\n  int i;\n\n  initlock(&amp;idelock, &quot;ide&quot;);\n  picenable(IRQ_IDE);\n  ioapicenable(IRQ_IDE, ncpu - 1);\n  idewait(0);\n  \n  \/\/ Check if disk 1 is present\n  outb(0x1f6, 0xe0 | (1&lt;&lt;4));\n  for(i=0; i&lt;1000; i++){\n    if(inb(0x1f7) != 0){\n      havedisk1 = 1;\n      break;\n    }\n  }\n  \n  \/\/ Switch back to disk 0.\n  outb(0x1f6, 0xe0 | (0&lt;&lt;4));\n}\n\n\/\/ Start the request for b.  Caller must hold idelock.\nstatic void\nidestart(struct buf *b)\n{\n  if(b == 0)\n    panic(&quot;idestart&quot;);\n\n  idewait(0);\n  outb(0x3f6, 0);  \/\/ generate interrupt\n  outb(0x1f2, 1);  \/\/ number of sectors\n  outb(0x1f3, b-&gt;sector &amp; 0xff);\n  outb(0x1f4, (b-&gt;sector &gt;&gt; 8) &amp; 0xff);\n  outb(0x1f5, (b-&gt;sector &gt;&gt; 16) &amp; 0xff);\n  outb(0x1f6, 0xe0 | ((b-&gt;dev&amp;1)&lt;&lt;4) | ((b-&gt;sector&gt;&gt;24)&amp;0x0f));\n  if(b-&gt;flags &amp; B_DIRTY){\n    outb(0x1f7, IDE_CMD_WRITE);\n    outsl(0x1f0, b-&gt;data, 512\/4);\n  } else {\n    outb(0x1f7, IDE_CMD_READ);\n  }\n}\n\n\/\/ Interrupt handler.\nvoid\nideintr(void)\n{\n  struct buf *b;\n\n  \/\/ Take first buffer off queue.\n  acquire(&amp;idelock);\n  if((b = idequeue) == 0){\n    release(&amp;idelock);\n    \/\/ cprintf(&quot;spurious IDE interrupt\\n&quot;);\n    return;\n  }\n  idequeue = b-&gt;qnext;\n\n  \/\/ Read data if needed.\n  if(!(b-&gt;flags &amp; B_DIRTY) &amp;&amp; idewait(1) &gt;= 0)\n    insl(0x1f0, b-&gt;data, 512\/4);\n  \n  \/\/ Wake process waiting for this buf.\n  b-&gt;flags |= B_VALID;\n  b-&gt;flags &amp;= ~B_DIRTY;\n  wakeup(b);\n  \n  \/\/ Start disk on next buf in queue.\n  if(idequeue != 0)\n    idestart(idequeue);\n\n  release(&amp;idelock);\n}\n\n\/\/PAGEBREAK!\n\/\/ Sync buf with disk. \n\/\/ If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.\n\/\/ Else if B_VALID is not set, read buf from disk, set B_VALID.\nvoid\niderw(struct buf *b)\n{\n  struct buf **pp;\n\n  if(!(b-&gt;flags &amp; B_BUSY))\n    panic(&quot;iderw: buf not busy&quot;);\n  if((b-&gt;flags &amp; (B_VALID|B_DIRTY)) == B_VALID)\n    panic(&quot;iderw: nothing to do&quot;);\n  if(b-&gt;dev != 0 &amp;&amp; !havedisk1)\n    panic(&quot;iderw: ide disk 1 not present&quot;);\n\n  acquire(&amp;idelock);  \/\/ DOC:acquire-lock\n\n  \/\/ Append b to idequeue.\n  b-&gt;qnext = 0;\n  for(pp=&amp;idequeue; *pp; pp=&amp;(*pp)-&gt;qnext)  \/\/ DOC:insert-queue\n    ;\n  *pp = b;\n  \n  \/\/ Start disk if necessary.\n  if(idequeue == b)\n    idestart(b);\n  \n  \/\/ Wait for request to finish.\n  \/\/ Assuming will not sleep too long: ignore proc-&gt;killed.\n  while((b-&gt;flags &amp; (B_VALID|B_DIRTY)) != B_VALID){\n    sleep(b, &amp;idelock);\n  }\n\n  release(&amp;idelock);\n}<\/pre>\n<p>\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3053\u3068\u306e\u96e3\u3057\u3044\u90e8\u5206\u306f\u3001\u3069\u3046\u3084\u3063\u3066\u591a\u304f\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u304b\u3001\u305d\u3057\u3066\u3069\u306e\u30ed\u30c3\u30af\u304c\u3069\u306e\u30c7\u30fc\u30bf\u3068\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u306e\u304b\u6c7a\u3081\u308b\u3053\u3068\u3067\u3042\u308b\u3002<br \/>\n\u305d\u3053\u306b\u306f\u3044\u304f\u3064\u304b\u306e\u57fa\u672c\u7684\u306a\u539f\u5247\u304c\u3042\u308b\u3002<br \/>\n\u6700\u521d\u306b\u3001\u4ed6\u306eCPU\u304c\u8aad\u307f\u66f8\u304d\u3067\u304d\u308b\u3088\u3046\u306a\u5909\u6570\u306f\u3044\u3064\u3067\u3082\u3001\u540c\u6642\u306b\u3042\u308bCPU\u304b\u3089\u66f8\u304d\u8fbc\u307e\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3002<br \/>\n\u30ed\u30c3\u30af\u306f\u3001\u305d\u306e2\u3064\u306e\u64cd\u4f5c\u304c\u30aa\u30fc\u30d0\u30fc\u30e9\u30c3\u30d7\u3057\u306a\u3044\u3088\u3046\u306b\u5c0e\u304f\u3079\u304d\u3067\u3042\u308b\u3002<br \/>\n\u6b21\u306b\u3001\u30ed\u30c3\u30af\u306f\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3092\u5fd8\u308c\u308b\u306a\u3002<br \/>\n\u3042\u308b\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u304c\u8907\u6570\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u307e\u305f\u304c\u308b\u5834\u5408\u3001\u5178\u578b\u7684\u306b\u306f\u3001\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u3053\u3068\u3092\u78ba\u5b9f\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u4e00\u3064\u306e\u30ed\u30c3\u30af\u306b\u3088\u3063\u3066\u3001\u305d\u306e\u5168\u3066\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u306f\u4fdd\u8b77\u3055\u308c\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30eb\u30fc\u30eb\u306f\u3001\u30ed\u30c3\u30af\u304c\u5fc5\u8981\u306a\u3068\u304d\u306e\u8a71\u3067\u3042\u308a\u3001\u30ed\u30c3\u30af\u304c\u4e0d\u5fc5\u8981\u306a\u5834\u5408\u306b\u3064\u3044\u3066\u306f\u4f55\u3082\u8a9e\u3063\u3066\u306f\u3044\u306a\u3044\u3002<br \/>\n\u305d\u3057\u3066\u3001\u52b9\u7387\u4e0a\u91cd\u8981\u306a\u70b9\u3067\u3042\u308b\u304c\u3001\u30ed\u30c3\u30af\u306f\u4e26\u5217\u6027\u3092\u640d\u306a\u3046\u306e\u3067\u3001\u30ed\u30c3\u30af\u306f\u4f7f\u3044\u904e\u304e\u306a\u3044\u3088\u3046\u306b\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002<br \/>\n\u52b9\u7387\u304c\u91cd\u8981\u3067\u306a\u3044\u5834\u5408\u3001\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u306e\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u3068\u3057\u3066\u4f7f\u3048\u3070\u3001\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u306f\u6c17\u306b\u3059\u308b\u5fc5\u8981\u306f\u306a\u304f\u306a\u308b\u3002<br \/>\n\u30ab\u30fc\u30cd\u30eb\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306a\u3089\u3001\u30ab\u30fc\u30cd\u30eb\u306b\u5165\u308b\u3068\u304d\u306b\u7372\u5f97\u3055\u308c\u3001\u30ab\u30fc\u30cd\u30eb\u3092\u51fa\u308b\u3068\u304d\u306b\u89e3\u653e\u3055\u308c\u308b\u3088\u3046\u306a\u30ed\u30c3\u30af\u304c\u4e00\u3064\u3042\u308c\u3070\u3044\u3044\u3002<br \/>\n\u591a\u304f\u306e\u30e6\u30cb\u30d7\u30ed\u30bb\u30c3\u30b5\u7528\u306eOS\u306e\u306f\u3001\u3068\u304d\u3069\u304d\u30b8\u30e3\u30a4\u30a2\u30f3\u30c8\u30ed\u30c3\u30af\uff08giant kernel lock\uff09\u3068\u547c\u3070\u308c\u308b\u3053\u306e\u3084\u308a\u65b9\u3092\u7528\u3044\u3066\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30c3\u30b5\u4e0a\u3067\u5b9f\u884c\u51fa\u6765\u308b\u3088\u3046\u79fb\u884c\u3057\u3066\u304d\u305f\u3002<br \/>\n\u3057\u304b\u3057\u3053\u306e\u65b9\u6cd5\u306f\u3001\u672c\u7269\u306e\u540c\u6642\u5b9f\u884c\u6027\u3092\u72a0\u7272\u306b\u3059\u308b\u3002<br \/>\n\u4e00\u5ea6\u306b\u3072\u3068\u3064\u306eCPU\u3060\u3051\u304c\u3001\u30ab\u30fc\u30cd\u30eb\u3067\u5b9f\u884c\u51fa\u6765\u308b\u306e\u307f\u3067\u3042\u308b\u3002<br \/>\n\u30ab\u30fc\u30cd\u30eb\u304c\u4f55\u304b\u91cd\u3044\u8a08\u7b97\u3092\u884c\u3046\u5834\u5408\u3001\u3088\u308a\u7d30\u304b\u3044\u7c92\u5ea6\u306e\u30ed\u30c3\u30af\u306e\u5927\u304d\u306a\u30bb\u30c3\u30c8\u3092\u6271\u3046\u306e\u304c\u3001\u3088\u308a\u52b9\u7387\u7684\u3067\u3042\u308b\u3002<br \/>\n\u3082\u3057\u305d\u3046\u306a\u3089\u3001\u30ab\u30fc\u30cd\u30eb\u306f\u8907\u6570\u306eCPU\u4e0a\u3067\u540c\u6642\u306b\u5b9f\u884c\u51fa\u6765\u308b\u3002<\/p>\n<p>\u7a76\u6975\u7684\u306b\u306f\u3001\u30ed\u30c3\u30af\u7c92\u5ea6\u306e\u9078\u629e\u306f\u3001\u4e26\u5217\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u304a\u3051\u308b\u8ab2\u984c\u3067\u3042\u308b\u3002<br \/>\nxv6\u306f\u3001\u5c11\u306a\u304f\u7c92\u5ea6\u304c\u7c97\u3044\u30c7\u30fc\u30bf\u69cb\u9020\u7279\u6709\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3002<br \/>\n\u4f8b\u3048\u3070xv6\u306f\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u3068\u305d\u306e\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u4fdd\u8b77\u3059\u308b\u305f\u3081\u306b\u4e00\u3064\u306e\u30ed\u30c3\u30af\u3092\u4f7f\u3046\u3002<br \/>\n\uff08\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u306b\u3064\u3044\u3066\u306f\u7b2c4\u7ae0\u3067\u8aac\u660e\u3059\u308b\u3002\uff09<br \/>\n\u3088\u308a\u7d30\u304b\u3044\u7c92\u5ea6\u306e\u65b9\u6cd5\u3067\u306f\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u306e\u500b\u5225\u306e\u30a8\u30f3\u30c8\u30ea\u4e0a\u3067\u52d5\u3044\u3066\u3044\u308b\u30b9\u30ec\u30c3\u30c9\u304c\u3001\u4e26\u884c\u3057\u3066\u7d9a\u884c\u51fa\u6765\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306b\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u5185\u306e\u3072\u3068\u3064\u306e\u30a8\u30f3\u30c8\u30ea\u6bce\u306b\u30ed\u30c3\u30af\u3092\u6301\u3064\u3060\u308d\u3046\u3002<br \/>\n\u3057\u304b\u3057\u306a\u304c\u3089\u3001\u30d7\u30ed\u30bb\u30b9\u30c6\u30fc\u30d6\u30eb\u5168\u4f53\u306b\u6e21\u308b\u30a4\u30f3\u30d0\u30ea\u30a2\u30f3\u30c8\u3092\u6301\u3064\u64cd\u4f5c\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u30ed\u30c3\u30af\u3092\u6301\u3061\u51fa\u3055\u306a\u304d\u3083\u306a\u3089\u306a\u3044\u306e\u3067\u3001\u8907\u96d1\u306b\u306a\u308b\u3002<br \/>\nxv6\u306e\u4f8b\u304c\u3001\u30ed\u30c3\u30af\u306e\u4f7f\u3044\u65b9\u3092\u4f1d\u3048\u308b\u624b\u52a9\u3051\u306b\u306a\u308b\u3053\u3068\u3092\u9858\u3046\u3002<\/p>\n<h3>\u611f\u60f3<\/h3>\n<p>\u304a\u3082\u3080\u308d\u306b\u7df4\u7fd2\u554f\u984c1\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3057\u8a66\u3059\u306a\u3089\u3001\u6c7a\u307e\u3063\u305f\u30d1\u30bf\u30fc\u30f3\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u8fbc\u3080\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u3001\u305d\u308c\u3092\u8907\u6570\u540c\u6642\u5b9f\u884c\u3059\u308b\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3082\u3057\u7af6\u5408\u72b6\u614b\u304c\u767a\u751f\u3057\u305f\u3089\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u306b\u6b20\u843d\u304c\u8d77\u304d\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\n\u305f\u3060\u3001\u78ba\u7387\u7684\u306b\u306a\u304b\u306a\u308a\u4f4e\u305d\u3046\u306a\u306e\u3067\u3069\u306e\u304f\u3089\u3044\u3084\u3063\u305f\u3089\u89b3\u6e2c\u53ef\u80fd\u304b\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u3002<br \/>\niderw\u3067\u306f\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u307e\u3067\u8fbf\u3063\u3066\u3001\u3059\u304b\u3055\u305a\u305d\u306e\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u306b\u65b0\u3057\u3044\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u8ffd\u52a0\u3057\u3066\u307e\u3059\uff08*pp = b;\u306e\u884c\uff09\u304c\u3001\u3042\u308bCPU\u306b\u304a\u3051\u308b\u305d\u306e\u884c\u306e\u51e6\u7406\u304c\u3001\u4ed6\u306eCPU\u304c\u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u307e\u3067\u8fbf\u3063\u305f\u76f4\u5f8c\u304b\u3064\u8ffd\u52a0\u306e\u76f4\u524d\u306b\u884c\u308f\u308c\u305f\u3089\u7af6\u5408\u72b6\u614b\u306b\u306a\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\n\u591a\u5206panic\u3057\u305f\u308a\u3068\u304b\u30c7\u30c3\u30c9\u30ed\u30c3\u30af\u3057\u305f\u308a\u3068\u304b\u306b\u306f\u306a\u3089\u306a\u3044\u306f\u305a\u306a\u306e\u3067\u3001\u8868\u9762\u4e0a\u306f\u4f55\u3082\u554f\u984c\u306a\u3044\u3088\u3046\u306b\u898b\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30de\u754c\u9688\u306e\u7b11\u3044\u8a71\u3068\u3057\u3066\u3001\u300c\u8b0e\u306eprint\u6587\u306b\u3001\u3053\u306e\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u305f\u3089\u4f55\u6545\u304b\u4ed6\u306e\u7b87\u6240\u3067\u554f\u984c\u304c\u8d77\u304d\u308b\u306e\u3067\u6ce8\u610f\u3002\u306a\u3093\u3066\u3044\u3046\u30b3\u30e1\u30f3\u30c8\u304c\u4ed8\u3044\u3066\u305f\u300d\u306a\u3093\u3066\u306e\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3053\u307e\u3067\u5206\u304b\u308b\u3088\u3046\u306b\u306a\u308b\u3068\u3001\uff08\u305d\u306e\u539f\u56e0\u3092\u653e\u7f6e\u3057\u3066\u308b\u3068\u3044\u3046\u610f\u5473\u3067\u306f\u7570\u5e38\u3067\u3059\u304c\uff09\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306e\u4ed5\u7d44\u307f\u7684\u306b\u306f\u7279\u306b\u4e0d\u601d\u8b70\u3067\u3082\u306a\u3093\u3067\u3082\u306a\u3044\u3067\u3059\u306d\u3002<br \/>\n\u305d\u3046\u3044\u3046\u5834\u5408\u30e1\u30e2\u30ea\u7ba1\u7406\u306b\u554f\u984c\u304c\u3042\u308b\u53ef\u80fd\u6027\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3061\u3087\u3063\u3068\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u9055\u3044\u306b\u3088\u3063\u3066\u6f5c\u5728\u7684\u306a\u7af6\u5408\u72b6\u614b\u304c\u8868\u9762\u5316\u3059\u308b\u304b\u3057\u306a\u3044\u304b\u306e\u5dee\u304c\u51fa\u3066\u308b\u3060\u3051\u3063\u3066\u306e\u304c\u3057\u3063\u304f\u308a\u6765\u307e\u3059\u3002<\/p>\n<p>\u4e26\u5217\u6027\u3092\u4e0a\u3052\u308b\u306b\u306f\u3001\u30ed\u30c3\u30af\u7c92\u5ea6\u3092\u7d30\u304b\u304f\u3057\u3066\u6570\u3092\u5897\u3084\u3059\u306e\u304c\u6709\u52b9\u3068\u3082\u66f8\u3044\u3066\u3042\u308a\u307e\u3059\u306d\u3002<br \/>\n\u4f3c\u305f\u3088\u3046\u306a\u4f8b\u3068\u3057\u3066\u3001DB\u306e\u30c6\u30fc\u30d6\u30eb\u30ed\u30c3\u30af\u3068\u884c\u30ed\u30c3\u30af\u306e\u4e26\u5217\u6027\u306b\u3064\u3044\u3066\u306e\u8a71\u304c\u3042\u308a\u307e\u3059\u306d\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-1433","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\/1433","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=1433"}],"version-history":[{"count":0,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/posts\/1433\/revisions"}],"wp:attachment":[{"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/media?parent=1433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/categories?post=1433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peta.okechan.net\/blog\/wp-json\/wp\/v2\/tags?post=1433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}