{"id":31533,"date":"2025-04-21T15:06:19","date_gmt":"2025-04-21T07:06:19","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/31533.html"},"modified":"2025-04-21T15:06:19","modified_gmt":"2025-04-21T07:06:19","slug":"%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%ae%9e%e9%aa%8clab-2system-callsmit-6-s081-fall-2020","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/31533.html","title":{"rendered":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020)"},"content":{"rendered":"<h4><span style=\"color:#fe2c24\">System calls:\u7cfb\u7edf\u8c03\u7528<\/span><\/h4>\n<p><span style=\"color:#0d0016\">\u57fa\u7840\u80cc\u666f&#xff1a;<\/span>\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u6ee1\u8db3\u4e09\u4e2a\u8981\u6c42&#xff1a;\u591a\u8def\u590d\u7528\u3001\u9694\u79bb\u548c\u4ea4\u4e92\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Unix\u8fdb\u7a0b\u4e4b\u95f4\u7684\u8bb8\u591a\u4ea4\u4e92\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u6587\u4ef6\u63cf\u8ff0\u7b26\u5b9e\u73b0\u7684<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>RISC-V\u6709\u4e09\u79cdCPU\u53ef\u4ee5\u6267\u884c\u6307\u4ee4\u7684\u6a21\u5f0f&#xff1a;<\/p>\n<p>\u673a\u5668\u6a21\u5f0f(Machine Mode):\u5728\u673a\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u7684\u6307\u4ee4\u5177\u6709\u5b8c\u5168\u7279\u6743,\u673a\u5668\u6a21\u5f0f\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e\u8ba1\u7b97\u673a<\/p>\n<p>\u7528\u6237\u6a21\u5f0f(User Mode)<\/p>\n<p>\u7ba1\u7406\u6a21\u5f0f(Supervisor Mode):\u5728\u7ba1\u7406\u6a21\u5f0f\u4e0b&#xff0c;CPU\u88ab\u5141\u8bb8\u6267\u884c\u7279\u6743\u6307\u4ee4<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070609-6805ee61a338b.jpg\" width=\"1200\" \/><\/p>\n<p>\u5e94\u7528\u7a0b\u5e8f\u53ea\u80fd\u6267\u884c\u7528\u6237\u6a21\u5f0f\u7684\u6307\u4ee4&#xff08;\u4f8b\u5982&#xff0c;\u6570\u5b57\u76f8\u52a0\u7b49&#xff09;\u88ab\u79f0\u4e3a\u5728<span style=\"color:#fe2c24\">\u7528\u6237\u7a7a\u95f4<\/span>\u4e2d\u8fd0\u884c<\/p>\n<p>\u5904\u4e8e\u7ba1\u7406\u6a21\u5f0f\u4e0b\u7684\u8f6f\u4ef6\u53ef\u4ee5\u6267\u884c\u7279\u6743\u6307\u4ee4&#xff0c;\u5e76\u88ab\u79f0\u4e3a\u5728<span style=\"color:#fe2c24\">\u5185\u6838\u7a7a\u95f4<\/span>\u4e2d\u8fd0\u884c\u3002<\/p>\n<p>\u5728\u5185\u6838\u7a7a\u95f4&#xff08;\u6216\u7ba1\u7406\u6a21\u5f0f&#xff09;\u4e2d\u8fd0\u884c\u7684\u8f6f\u4ef6\u88ab\u79f0\u4e3a<span style=\"color:#fe2c24\">\u5185\u6838<\/span>\u3002<\/p>\n<h3><span style=\"color:#fe2c24\">\u7528\u6237\u6001\u548c\u6838\u5fc3\u6001\u4ee3\u8868\u4e86\u7a0b\u5e8f\u6267\u884c\u65f6\u6240\u5904\u7684\u4e24\u79cd\u4e0d\u540c\u7684\u7279\u6743\u7ea7\u522b&#xff0c;\u800c\u7cfb\u7edf\u8c03\u7528\u5219\u662f\u7528\u6237\u6001\u7a0b\u5e8f\u4e0e\u6838\u5fc3\u6001\u7a0b\u5e8f\u4e4b\u95f4\u7684\u6865\u6881&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;<\/span><\/h3>\n<p><span style=\"color:#0d0016\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><\/p>\n<p>\u5b8f\u5185\u6838&#xff08;monolithic kernel&#xff09;&#xff1a;\u6574\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u90fd\u9a7b\u7559\u5728\u5185\u6838\u4e2d&#xff0c;\u8fd9\u6837\u6240\u6709\u7cfb\u7edf\u8c03\u7528\u7684\u5b9e\u73b0\u90fd\u4ee5\u7ba1\u7406\u6a21\u5f0f\u8fd0\u884c\u3002<\/p>\n<p>\u4f18\u70b9&#xff1a;\u4ee5\u5b8c\u5168\u7684\u786c\u4ef6\u7279\u6743\u8fd0\u884c\/\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\u90e8\u5206\u66f4\u5bb9\u6613\u5408\u4f5c<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u540c\u90e8\u5206\u4e4b\u95f4\u7684\u63a5\u53e3\u901a\u5e38\u5f88\u590d\u6742<\/p>\n<p><span style=\"color:#fe2c24\">\u7ba1\u7406\u6a21\u5f0f\u4e2d\u7684\u9519\u8bef\u7ecf\u5e38\u4f1a\u5bfc\u81f4\u5185\u6838\u5931\u8d25\u3002\u5982\u679c\u5185\u6838\u5931\u8d25&#xff0c;\u8ba1\u7b97\u673a\u505c\u6b62\u5de5\u4f5c&#xff0c;\u56e0\u6b64\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u4e5f\u4f1a\u5931\u8d25\u3002\u8ba1\u7b97\u673a\u5fc5\u987b\u91cd\u542f\u624d\u80fd\u518d\u6b21\u4f7f\u7528\u3002<\/span><\/p>\n<p>\u5fae\u5185\u6838&#xff08;microkernel&#xff09;&#xff1a;\u6700\u5927\u9650\u5ea6\u5730\u51cf\u5c11\u5728\u7ba1\u7406\u6a21\u5f0f\u4e0b\u8fd0\u884c\u7684\u64cd\u4f5c\u7cfb\u7edf\u4ee3\u7801\u91cf&#xff0c;\u5e76\u5728\u7528\u6237\u6a21\u5f0f\u4e0b\u6267\u884c\u5927\u90e8\u5206\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p>\u8865\u5145&#xff1a;\u5355\u673a\u5fae\u5185\u6838\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u51e0\u4e4e\u65e0\u4e00\u4f8b\u5916\u5730\u90fd\u91c7\u7528\u5ba2\u6237\/\u670d\u52a1\u5668\u6a21\u5f0f&#xff0c;\u5c06\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6700\u57fa\u672c\u7684\u90e8\u5206\u653e\u5165\u5185\u6838\u4e2d&#xff0c;\u800c\u628a\u64cd\u4f5c\u7cfb\u7edf\u7684\u7edd\u5927\u90e8\u5206\u529f\u80fd\u90fd\u653e\u5728\u5fae\u5185\u6838\u5916\u9762\u7684\u4e00\u7ec4\u670d\u52a1\u5668(\u8fdb\u7a0b)\u4e2d\u5b9e\u73b0\u3002<\/p>\n<h2><span style=\"color:#fe2c24\">Xv6\u662f\u4f5c\u4e3a\u4e00\u4e2a\u5b8f\u5185\u6838\u5b9e\u73b0\u7684<\/span><\/h2>\n<p><span style=\"color:#0d0016\">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/span><\/p>\n<p>\u5185\u6838\u7528\u6765\u5b9e\u73b0\u8fdb\u7a0b\u7684\u673a\u5236\u5305\u62ec\u7528\u6237\/\u7ba1\u7406\u6a21\u5f0f\u6807\u5fd7\u3001\u5730\u5740\u7a7a\u95f4\u548c\u7ebf\u7a0b\u7684\u65f6\u95f4\u5207\u7247\u3002\u00a0<\/p>\n<p>\u4e00\u4e2a\u8fdb\u7a0b\u6700\u91cd\u8981\u7684\u5185\u6838\u72b6\u6001\u7247\u6bb5\u662f\u5b83\u7684\u9875\u8868\u3001\u5185\u6838\u6808\u533a\u548c\u8fd0\u884c\u72b6\u6001<\/p>\n<p>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u4e00\u4e2a\u6267\u884c\u7ebf\u7a0b&#xff08;\u6216\u7b80\u79f0\u7ebf\u7a0b&#xff09;\u6765\u6267\u884c\u8fdb\u7a0b\u7684\u6307\u4ee4<\/p>\n<p>\u6bcf\u4e2a\u8fdb\u7a0b\u6709\u4e24\u4e2a\u6808\u533a&#xff1a;\u4e00\u4e2a\u7528\u6237\u6808\u533a\u548c\u4e00\u4e2a\u5185\u6838\u6808\u533a<\/p>\n<p>\u8fdb\u7a0b\u7684\u7ebf\u7a0b\u5728\u4e3b\u52a8\u4f7f\u7528\u5b83\u7684\u7528\u6237\u6808\u548c\u5185\u6838\u6808\u4e4b\u95f4\u4ea4\u66ff\u3002\u5185\u6838\u6808\u662f\u72ec\u7acb\u7684&#xff08;\u5e76\u4e14\u4e0d\u53d7\u7528\u6237\u4ee3\u7801\u7684\u4fdd\u62a4&#xff09;&#xff0c;\u56e0\u6b64\u5373\u4f7f\u4e00\u4e2a\u8fdb\u7a0b\u7834\u574f\u4e86\u5b83\u7684\u7528\u6237\u6808&#xff0c;\u5185\u6838\u4f9d\u7136\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<h3>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<span style=\"color:#1a439c\">\u4e24\u4e2a\u4f8b\u5b50&#xff1a;<\/span><\/h3>\n<h3><span style=\"color:#4da8ee\">\u8c03\u7528\u7cfb\u7edf\u8c03\u7528&#xff1a;<\/span><\/h3>\n<p><span style=\"color:#4da8ee\">1.\u7528\u6237\u7a0b\u5e8f\u51c6\u5907\u8c03\u7528exec&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070610-6805ee62de034.jpg\" width=\"1200\" \/><\/p>\n<p><span style=\"color:#4da8ee\">2.\u6267\u884cecall\u6307\u4ee4&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"565\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070612-6805ee6429991.jpg\" width=\"1200\" \/><\/p>\n<p><span style=\"color:#4da8ee\">3.\u5185\u6838\u5904\u7406\u7cfb\u7edf\u8c03\u7528<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070613-6805ee6507331.jpg\" width=\"1200\" \/><\/p>\n<p><span style=\"color:#4da8ee\">4.\u6267\u884csys_exec\u51fd\u6570<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070614-6805ee664cef2.jpg\" width=\"1200\" \/><\/p>\n<p><span style=\"color:#4da8ee\">5.\u8fd4\u56de\u7528\u6237\u7a0b\u5e8f&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070615-6805ee6794ca1.jpg\" width=\"1200\" \/><\/p>\n<p><span style=\"color:#4da8ee\">6&#xff1a;\u9519\u8bef\u5904\u7406&#xff1a;<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1000\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070616-6805ee68d8b42.jpg\" width=\"1200\" \/><\/p>\n<h3>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/h3>\n<h3><span style=\"color:#6eaad7\">\u00a0\u7cfb\u7edf\u8c03\u7528\u53c2\u6570&#xff1a;<\/span><\/h3>\n<p>\u7cfb\u7edf\u8c03\u7528\u5982\u4f55\u5b89\u5168\u5730\u5904\u7406\u7528\u6237\u7a7a\u95f4\u4f20\u9012\u7ed9\u5185\u6838\u7684\u53c2\u6570&#xff0c;\u7279\u522b\u662f\u5f53\u8fd9\u4e9b\u53c2\u6570\u662f\u5185\u5b58\u5730\u5740&#xff08;\u5982\u6307\u9488&#xff09;\u65f6\u3002<\/p>\n<h6>\u7cfb\u7edf\u8c03\u7528\u53c2\u6570\u4f20\u9012&#xff1a;\u5185\u6838\u7684\u9677\u9631\u5904\u7406\u4ee3\u7801&#xff08;trap handler&#xff09;\u4f1a\u4fdd\u5b58\u8fd9\u4e9b\u5bc4\u5b58\u5668\u7684\u503c\u5230\u5f53\u524d\u8fdb\u7a0b\u7684\u9677\u9631\u6846\u67b6&#xff08;trap frame&#xff09;\u4e2d&#xff0c;\u5185\u6838\u4ee3\u7801\u968f\u540e\u53ef\u4ee5\u4ece\u9677\u9631\u6846\u67b6\u4e2d\u68c0\u7d22\u8fd9\u4e9b\u53c2\u6570\u3002<\/h6>\n<h6>\u7528\u6237\u7a7a\u95f4\u4e0e\u5185\u6838\u7a7a\u95f4&#xff1a;\u7528\u6237\u7a7a\u95f4\u548c\u5185\u6838\u7a7a\u95f4\u662f\u8ba1\u7b97\u673a\u5185\u5b58\u4e2d\u7684\u4e24\u4e2a\u4e0d\u540c\u533a\u57df&#xff0c;\u5206\u522b\u7528\u4e8e\u5b58\u653e\u7528\u6237\u7a0b\u5e8f\u548c\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u7684\u4ee3\u7801\u548c\u6570\u636e<\/h6>\n<h6>\u9875\u8868\u6620\u5c04&#xff1a;\u9875\u8868\u662f\u64cd\u4f5c\u7cfb\u7edf\u7528\u6765\u5c06\u865a\u62df\u5185\u5b58\u5730\u5740\u6620\u5c04\u5230\u7269\u7406\u5185\u5b58\u5730\u5740\u7684\u6570\u636e\u7ed3\u6784\u3002\u7528\u6237\u7a7a\u95f4\u548c\u5185\u6838\u7a7a\u95f4\u6709\u5404\u81ea\u7684\u9875\u8868&#xff0c;\u56e0\u6b64\u5b83\u4eec\u7684\u865a\u62df\u5730\u5740\u5230\u7269\u7406\u5730\u5740\u7684\u6620\u5c04\u662f\u4e0d\u540c\u7684<\/h6>\n<h6>\u5b89\u5168\u7684\u6570\u636e\u4f20\u8f93&#xff1a;\u7528\u6237\u7a7a\u95f4\u548c\u5185\u6838\u7a7a\u95f4\u4e4b\u95f4\u4f20\u8f93\u6570\u636e&#xff1a;\u7279\u6b8a\u7684\u51fd\u6570&#xff1a;\u7528\u6237\u63d0\u4f9b\u7684\u865a\u62df\u5730\u5740\u548c\u5185\u6838\u7f13\u51b2\u533a\u4e4b\u95f4\u590d\u5236\u6570\u636e&#xff0c;\u540c\u65f6\u786e\u4fdd\u4e0d\u4f1a\u8fdd\u53cd\u5185\u5b58\u4fdd\u62a4\u89c4\u5219\u3002<\/h6>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<h3>\u5148\u653e\u4e24\u4e2a\u6211\u9047\u5230\u7684\u95ee\u9898&#xff1a;<\/h3>\n<h3>1.\u4f7f\u5f97ifconfig\u547d\u4ee4\u53ea\u51fa\u73b0\u4e86lo&#xff08;\u672c\u5730\u73af\u56de&#xff09;<\/h3>\n<p><span style=\"color:#fe2c24\">\u6ce8\u610f&#xff1a;\u9700\u8981root\u6743\u9650&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;<\/span><\/p>\n<p>\/\/\u67e5\u770b\u662f\u5426\u6709ens33\u7f51\u5361<br \/>\nifconfig -a<br \/>\n\/\/\u542f\u52a8\u7f51\u5361<br \/>\nifconfig ens33 up<br \/>\n\/\/\u518d\u8f93\u5165<br \/>\ndhclient<br \/>\n\/\/\u6700\u540e\u8f93\u5165<br \/>\ndhclient ens33<br \/>\n\/\/\u68c0\u67e5<br \/>\nifconfig <\/p>\n<h3>2.\u63d0\u4ea4\u4e86\u4fee\u6539&#xff0c;\u4f46\u662f\u53ea\u63d0\u4ea4\u4e86\u4e00\u534a&#xff0c;\u4e8e\u662fbe like:<\/h3>\n<h3>\u60a8\u5bf9\u4e0b\u5217\u6587\u4ef6\u7684\u672c\u5730\u4fee\u6539\u5c06\u88ab\u68c0\u51fa\u64cd\u4f5c\u8986\u76d6&#xff1a; \u00a0\u00a0 \u00a0<\/h3>\n<h3>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Makefile \u00a0\u00a0 <\/h3>\n<h3>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0grade-lab-util <\/h3>\n<h3>\u8bf7\u5728\u5207\u6362\u5206\u652f\u524d\u63d0\u4ea4\u6216\u8d2e\u85cf\u60a8\u7684\u4fee<\/h3>\n<h3>Tips:<span style=\"color:#4d4d4d\">\u6682\u65f6\u4e0d\u60f3\u63d0\u4ea4\u8fd9\u4e9b\u4fee\u6539&#xff0c;\u4f46\u53c8\u4e0d\u60f3\u4e22\u5931\u5b83\u4eec&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u8d2e\u85cf\u547d\u4ee4\u5c06\u5176\u4fdd\u5b58\u8d77\u6765\u3002<\/span><\/h3>\n<p><span style=\"color:#fe2c24\">\u4e8e\u662f\u6211\u9009\u62e9\u5148git stash<\/span><\/p>\n<p>\u6062\u590d\u8d2e\u85cf\u7684\u4fee\u6539\u53ef\u4ee5\u4f7f\u7528git stash apply\u547d\u4ee4<\/p>\n<p>_____________________________________________________________________________<\/p>\n<p>\u6b63\u6587\u5f00\u59cb&#xff1a;<\/p>\n<p>\u6839\u636e\u5b9e\u9a8c\u63d0\u793a&#xff1a;<\/p>\n<ul>\n<li>\u5c06\u00a0$U\/_trace\u00a0\u6dfb\u52a0\u5230\u00a0Makefile\u00a0\u7684\u00a0UPROGS\u00a0\u4e2d<\/li>\n<li>\u8fd0\u884c make qemu &#xff0c; \u4f60\u5c06\u770b\u5230\u7f16\u8bd1\u5668\u65e0\u6cd5\u7f16\u8bd1 user\/trace.c &#xff0c;\u56e0\u4e3a\u7cfb\u7edf\u8c03\u7528\u7684\u7528\u6237\u7a7a\u95f4\u5b58\u6839\u8fd8\u4e0d\u5b58\u5728<\/li>\n<li><span style=\"color:#ff9900\">\u5c06\u7cfb\u7edf\u8c03\u7528\u7684\u539f\u578b\u6dfb\u52a0\u5230 user\/user.h\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e00\u6b65&#xff1a;int trace(int);\u00a0 \u00a0 \u00a0<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/p>\n<p>\u4e3a\u4ec0\u4e48\u662f\u6574\u578b\u5462&#xff1f;\u00a0 if (trace(atoi(argv[1])) &lt; 0)\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/p>\n<p>\u89e3\u91ca&#xff1a;argv[0]\u00a0\u901a\u5e38\u662f\u7a0b\u5e8f\u7684\u540d\u79f0&#xff0c;\u800c\u00a0argv[1]\u3001argv[2]\u00a0\u7b49\u5219\u5305\u542b\u4e86\u4f20\u9012\u7ed9\u7a0b\u5e8f\u7684<span style=\"color:#0d0016\">\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/span>argv[1]\u00a0\u88ab\u671f\u671b\u5305\u542b\u4e00\u4e2a\u53ef\u4ee5\u8f6c\u6362\u4e3a\u6574\u6570\u7684<span style=\"color:#a2e043\">\u5b57\u7b26\u4e32<\/span>&#xff0c;\u8be5\u6574\u6570\u5c06\u4f5c\u4e3a\u00a0trace\u00a0\u51fd\u6570\u7684\u53c2\u6570&#xff0c;<span style=\"color:#a2e043\">atoi\u7528\u4e8e\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u6570,trace\u00a0\u51fd\u6570\u6267\u884c\u5176\u64cd\u4f5c&#xff0c;\u5e76\u8fd4\u56de\u4e00\u4e2a\u6574\u6570\u4f5c\u4e3a\u7ed3\u679c\u00a0<\/span><span style=\"color:#ff9900\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/span>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/p>\n<\/li>\n<li><span style=\"color:#ff9900\">\u5c06\u5b58\u6839\u6dfb\u52a0\u5230 user\/usys.pl\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/span>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e8c\u6b65&#xff1a;entry(&#034;trace&#034;);<\/span><\/p>\n<p>usys.pl\u6587\u4ef6\u662f\u7528\u4e8e\u5b9a\u4e49\u548c\u5b9e\u73b0\u7cfb\u7edf\u8c03\u7528\u7528\u6237\u7a7a\u95f4\u63a5\u53e3\u7684\u5173\u952e\u7ec4\u4ef6\u4e4b\u4e00,\u5f00\u53d1\u8005\u53ef\u4ee5\u65b9\u4fbf\u5730\u6dfb\u52a0<span style=\"color:#a2e043\">\u65b0\u7684\u7cfb\u7edf\u8c03\u7528<\/span>&#xff0c;\u5e76\u5728\u7528\u6237\u7a0b\u5e8f\u548c\u5185\u6838\u4e4b\u95f4\u5efa\u7acb\u5fc5\u8981\u7684\u4ea4\u4e92\u673a\u5236\u3002<\/p>\n<\/li>\n<li><span style=\"color:#ff9900\">\u4ee5\u53ca\u5c06\u7cfb\u7edf\u8c03\u7528\u53f7\u6dfb\u52a0\u5230 kernel\/syscall.h \u4e2d\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <\/span><span style=\"color:#fe2c24\">\u00a0\u7b2c\u4e09\u6b65&#xff1a;#define SYS_trace \u00a022<\/span><\/li>\n<\/ul>\n<h4><span style=\"color:#fe2c24\">\u4ee5\u4e0a\u4e09\u6b65\u5c5e\u4e8e\u6a21\u4eff\u7cfb\u7edf\u6587\u4ef6\u4e2d\u7684\u5df2\u7ecf\u5b58\u5728\u7684\u4ee3\u7801\u8bed\u53e5&#xff0c;\u6839\u636e\u63d0\u793a\u53ef\u4ee5\u8f7b\u677e\u62ff\u4e0b&#xff01;&#xff01;&#xff01;&#xff01;<\/span><\/h4>\n<p>\u00a0user\/usys.S\u6587\u4ef6\u4e2d&#xff1a;li a7, SYS_fork\u00a0\u6307\u4ee4\u5c31\u662f\u628a\u00a0<span style=\"color:#a2e043\">SYS_fork\u00a0\u7684\u7cfb\u7edf\u8c03\u7528\u53f7<\/span>\u653e\u5165<span style=\"color:#a2e043\">\u00a0a7\u00a0\u5bc4\u5b58\u5668<\/span>&#xff0c;\u4f7f\u7528\u00a0<span style=\"color:#a2e043\">ecall\u00a0\u6307\u4ee4\u8fdb\u5165\u7cfb\u7edf\u5185\u6838<\/span>&#xff0c;\u00a0ecall\u00a0\u6307\u4ee4\u4f1a\u8df3\u8f6c\u5230\u00a0kernel\/syscall.c\u00a0\u4e2d<span style=\"color:#a2e043\">\u00a0syscall\u00a0\u51fd\u6570\u5904\u6267\u884c<\/span><\/p>\n<ul>\n<li><span style=\"color:#fe2c24\">\u7b2c\u56db\u6b65&#xff1a;<\/span><\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">syscalls[num]();\u00a0\u51fd\u6570\u8f6c\u5230\u5b9a\u4e49&#xff08;F12&#xff09;<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u628a\u65b0\u589e\u7684\u00a0trace\u00a0\u7cfb\u7edf\u8c03\u7528\u6dfb\u52a0\u5230\u51fd\u6570\u6307\u9488\u6570\u7ec4\u00a0*syscalls[]\u00a0\u4e0a<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u5728\u6587\u4ef6\u5f00\u5934\u7ed9\u5185\u6838\u6001\u7684\u7cfb\u7edf\u8c03\u7528\u00a0trace\u00a0\u52a0\u4e0a\u58f0\u660e<\/span><\/p>\n<\/p>\n<ul>\n<li>trace\u00a0\u7cfb\u7edf\u8c03\u7528\u5e94\u8be5\u6709\u4e00\u4e2a\u53c2\u6570&#xff0c;\u4e00\u4e2a\u6574\u6570\u201cmask(\u63a9\u7801)\u201d&#xff0c;\u5176\u6307\u5b9a\u8981\u8ddf\u8e2a\u7684\u7cfb\u7edf\u8c03\u7528\u3002<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u00a0 \u00a0 \u00a0 \u00a0\u7b2c\u4e94\u6b65&#xff1a;\u5728\u00a0kernel\/proc.h\u00a0\u6587\u4ef6\u7684\u00a0proc\u00a0\u7ed3\u6784\u4f53\u4e2d&#xff0c;\u65b0\u6dfb\u52a0\u4e00\u4e2a\u53d8\u91cf\u00a0mask\u00a0<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5728\u00a0kernel\/sysproc.c\u00a0\u7ed9\u51fa\u00a0sys_trace\u00a0\u51fd\u6570\u7684\u5177\u4f53\u5b9e\u73b0<\/span><\/p>\n<\/p>\n<p>uint64<br \/>\nsys_trace(void)<br \/>\n{<br \/>\n  int mask;<br \/>\n  \/\/ \u53d6 a0 \u5bc4\u5b58\u5668\u4e2d\u7684\u503c\u8fd4\u56de\u7ed9 mask<br \/>\n  \/\/argint\u51fd\u6570\u7528\u4e8e\u5b89\u5168\u5730\u4ece\u7528\u6237\u6001\u4f20\u9012\u7684\u53c2\u6570\u4e2d\u8bfb\u53d6\u6574\u6570\u503c<br \/>\n  \/\/\u56e0\u4e3a\u76f4\u63a5\u8bfb\u53d6\u7528\u6237\u6001\u5185\u5b58\u53ef\u80fd\u4f1a\u53d7\u5230\u6076\u610f\u7528\u6237\u7684\u5f71\u54cd<br \/>\n  if(argint(0, &amp;mask) &lt; 0)<br \/>\n    return -1;<\/p>\n<p>  \/\/ \u628a mask \u4f20\u7ed9\u73b0\u6709\u8fdb\u7a0b\u7684 mask<br \/>\n  \/\/\u5047\u8bbemyproc()\u662f\u4e00\u4e2a\u8fd4\u56de\u5f53\u524d\u8fdb\u7a0b\u63a7\u5236\u5757&#xff08;PCB&#xff09;\u6307\u9488\u7684\u51fd\u6570<br \/>\n  \/\/\u5141\u8bb8\u7cfb\u7edf\u8c03\u7528\u76f4\u63a5\u4fee\u6539\u5f53\u524d\u8fdb\u7a0b\u7684\u72b6\u6001&#xff0c;\u4ece\u800c\u5b9e\u73b0\u4e86\u52a8\u6001\u8c03\u6574\u8ddf\u8e2a\u63a9\u7801<br \/>\n  myproc()-&gt;mask &#061; mask;<br \/>\n  return 0;<br \/>\n}<br \/>\n\/\/\u5f53\u9700\u8981\u4fee\u6539\u6216\u6269\u5c55\u7cfb\u7edf\u8c03\u7528\u65f6&#xff0c;\u53ea\u9700\u4fee\u6539\u76f8\u5e94\u7684\u51fd\u6570\u5373\u53ef&#xff0c;\u800c\u65e0\u9700\u66f4\u6539\u7528\u6237\u6001\u7a0b\u5e8f\u3002<\/p>\n<ul>\n<li>proc\u00a0\u7ed3\u6784\u4f53(\u89c1\u00a0kernel\/proc.h\u00a0)\u91cc\u7684\u00a0name\u00a0\u662f\u8868\u793a\u4e0e\u6574\u4e2aproc\u7ed3\u6784\u4f53&#xff08;\u5373\u8fdb\u7a0b&#xff09;\u76f8\u5173\u8054\u7684\u540d\u79f0\u3002name\u662f\u8fdb\u7a0b\u7684\u540d\u79f0&#xff0c;\u7528\u4e8e\u8c03\u8bd5\u6216\u5176\u4ed6\u9700\u8981\u5f15\u7528\u6216\u6807\u8bc6\u8fdb\u7a0b\u7684\u60c5\u51b5\u3002\u8981\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4<\/li>\n<\/ul>\n<p><span style=\"color:#fe2c24\">\u7b2c\u516d\u6b65&#xff1a;\u7cfb\u7edf\u8c03\u7528\u540d\u5b57\u4e00\u5b9a\u8981\u6309\u987a\u5e8f<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u7cfb\u7edf\u8c03\u7528\u53f7\u662f\u4ece\u00a01\u00a0\u5f00\u59cb&#xff0c;\u5b9a\u4e49\u7b2c\u4e00\u4e2a\u4e3a\u7a7a\u5b57\u7b26\u4e32<\/span><\/p>\n<p>static char *syscall_names[] &#061; {<br \/>\n  &#034;&#034;, &#034;fork&#034;, &#034;exit&#034;, &#034;wait&#034;, &#034;pipe&#034;,<br \/>\n  &#034;read&#034;, &#034;kill&#034;, &#034;exec&#034;, &#034;fstat&#034;, &#034;chdir&#034;,<br \/>\n  &#034;dup&#034;, &#034;getpid&#034;, &#034;sbrk&#034;, &#034;sleep&#034;, &#034;uptime&#034;,<br \/>\n  &#034;open&#034;, &#034;write&#034;, &#034;mknod&#034;, &#034;unlink&#034;, &#034;link&#034;,<br \/>\n  &#034;mkdir&#034;, &#034;close&#034;, &#034;trace&#034;};<\/p>\n<p>\u68c0\u67e5\u67d0\u4e2a\u7279\u5b9a\u7684\u6807\u5fd7&#xff08;\u7531num\u6307\u5b9a&#xff09;\u662f\u5426\u5728p\u6307\u5411\u7684\u8fdb\u7a0b\u7684mask\u5b57\u6bb5\u4e2d\u88ab\u8bbe\u7f6e<\/p>\n<p>1 &lt;&lt; num&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u5de6\u79fb\u64cd\u4f5c<\/p>\n<p>&amp; p-&gt;mask&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u6309\u4f4d\u4e0e&#xff08;AND&#xff09;\u64cd\u4f5c<\/p>\n<p>(1 &lt;&lt; num) &amp; p-&gt;mask\u7684\u7ed3\u679c\u4e0d\u4e3a0&#xff08;\u5b9e\u9645\u4e0a\u662f1 &lt;&lt; num\u7684\u7ed3\u679c\u672c\u8eab&#xff0c;\u56e0\u4e3a\u53ea\u6709\u5728\u5bf9\u5e94\u4f4d\u90fd\u4e3a1\u65f6&#xff0c;\u6309\u4f4d\u4e0e\u64cd\u4f5c\u624d\u4f1a\u5728\u8be5\u4f4d\u4ea7\u751f1&#xff09;&#xff0c;\u6761\u4ef6\u4e3a\u771f\u3002<\/p>\n<p>if((1 &lt;&lt; num) &amp; p-&gt;mask) {<br \/>\n      printf(&#034;%d: syscall %s -&gt; %d\\\\n&#034;, p-&gt;pid, syscall_names[num], p-&gt;trapframe-&gt;a0);<br \/>\n    } <\/p>\n<p><span style=\"color:#fe2c24\">\u7b2c\u4e03\u6b65&#xff1a;\u5728\u00a0kernel\/proc.c\u00a0\u4e2d\u00a0fork\u00a0\u51fd\u6570\u8c03\u7528\u65f6&#xff0c;\u6dfb\u52a0\u5b50\u8fdb\u7a0b\u590d\u5236\u7236\u8fdb\u7a0b\u7684\u00a0mask\u00a0\u7684\u4ee3\u7801<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0np-&gt;mask &#061; p-&gt;mask;<\/span><\/p>\n<\/p>\n<p>\u8fd0\u884c&#xff1a;make qemu<\/p>\n<p>$ trace 32 grep hello README&#xff0c;<\/p>\n<p>$ trace 2147483647 grep hello README&#xff0c;<\/p>\n<p>$ grep hello README&#xff0c;<\/p>\n<p>$ trace 2 usertests forkforkfor<\/p>\n<h3>\u00a0<span style=\"color:#0d0016\">\u9000\u51fa xv6 &#xff0c;\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5\u68c0\u67e5\u7ed3\u679c\u662f\u5426\u6b63\u786e:.\/grade-lab-syscall trace<\/span><\/h3>\n<\/p>\n<p> \u00a0<\/p>\n<p><span style=\"color:#a2e043\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf11\u6b21\u3002Xv6\u662f\u4f5c\u4e3a\u4e00\u4e2a\u5b8f\u5185\u6838\u5b9e\u73b0\u7684System calls:\u7cfb\u7edf\u8c03\u7528\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u6ee1\u8db3\u4e09\u4e2a\u8981\u6c42\uff1a\u591a\u8def\u590d\u7528\u3001\u9694\u79bb\u548c\u4ea4\u4e92\u3002Unix\u8fdb\u7a0b\u4e4b\u95f4\u7684\u8bb8\u591a\u4ea4\u4e92\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u6587\u4ef6\u63cf\u8ff0\u7b26\u5b9e\u73b0\u7684\u5728\u673a\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u7684\u6307\u4ee4\u5177\u6709\u5b8c\u5168\u7279\u6743,\u673a\u5668\u6a21\u5f0f\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e\u8ba1\u7b97\u673a\u5728\u7ba1\u7406\u6a21\u5f0f\u4e0b\uff0cCPU\u88ab\u5141\u8bb8\u6267\u884c\u7279\u6743\u6307\u4ee4\u5e94\u7528\u7a0b\u5e8f\u53ea\u80fd\u6267\u884c\u7528\u6237\u6a21\u5f0f\u7684\u6307\u4ee4\uff08\u4f8b\u5982\uff0c\u6570\u5b57\u76f8\u52a0\u7b49\uff09\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u5904\u4e8e\u7ba1\u7406\u6a21\u5f0f\u4e0b\u7684\u8f6f\u4ef6\u53ef\u4ee5\u6267\u884c\u7279\u6743\u6307\u4ee4\uff0c\u5e76\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u3002\u5728\u5185\u6838\u7a7a\u95f4\uff08\u6216\u7ba1\u7406\u6a21\u5f0f\uff09\u4e2d\u8fd0\u884c\u7684\u8f6f\u4ef6\u88ab\u79f0\u4e3a\u5185\u6838\u3002_\u5b9e\u9a8c2:system calls<\/p>\n","protected":false},"author":2,"featured_media":31526,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,44],"topic":[],"class_list":["post-31533","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/31533.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf11\u6b21\u3002Xv6\u662f\u4f5c\u4e3a\u4e00\u4e2a\u5b8f\u5185\u6838\u5b9e\u73b0\u7684System calls:\u7cfb\u7edf\u8c03\u7528\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u6ee1\u8db3\u4e09\u4e2a\u8981\u6c42\uff1a\u591a\u8def\u590d\u7528\u3001\u9694\u79bb\u548c\u4ea4\u4e92\u3002Unix\u8fdb\u7a0b\u4e4b\u95f4\u7684\u8bb8\u591a\u4ea4\u4e92\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u6587\u4ef6\u63cf\u8ff0\u7b26\u5b9e\u73b0\u7684\u5728\u673a\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u7684\u6307\u4ee4\u5177\u6709\u5b8c\u5168\u7279\u6743,\u673a\u5668\u6a21\u5f0f\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e\u8ba1\u7b97\u673a\u5728\u7ba1\u7406\u6a21\u5f0f\u4e0b\uff0cCPU\u88ab\u5141\u8bb8\u6267\u884c\u7279\u6743\u6307\u4ee4\u5e94\u7528\u7a0b\u5e8f\u53ea\u80fd\u6267\u884c\u7528\u6237\u6a21\u5f0f\u7684\u6307\u4ee4\uff08\u4f8b\u5982\uff0c\u6570\u5b57\u76f8\u52a0\u7b49\uff09\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u5904\u4e8e\u7ba1\u7406\u6a21\u5f0f\u4e0b\u7684\u8f6f\u4ef6\u53ef\u4ee5\u6267\u884c\u7279\u6743\u6307\u4ee4\uff0c\u5e76\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u3002\u5728\u5185\u6838\u7a7a\u95f4\uff08\u6216\u7ba1\u7406\u6a21\u5f0f\uff09\u4e2d\u8fd0\u884c\u7684\u8f6f\u4ef6\u88ab\u79f0\u4e3a\u5185\u6838\u3002_\u5b9e\u9a8c2:system calls\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/31533.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-21T07:06:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070609-6805ee61a338b.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/31533.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/31533.html\",\"name\":\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-21T07:06:19+00:00\",\"dateModified\":\"2025-04-21T07:06:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/31533.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/31533.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/31533.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/31533.html","og_locale":"zh_CN","og_type":"article","og_title":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e24\u6b21\uff0c\u6536\u85cf11\u6b21\u3002Xv6\u662f\u4f5c\u4e3a\u4e00\u4e2a\u5b8f\u5185\u6838\u5b9e\u73b0\u7684System calls:\u7cfb\u7edf\u8c03\u7528\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u6ee1\u8db3\u4e09\u4e2a\u8981\u6c42\uff1a\u591a\u8def\u590d\u7528\u3001\u9694\u79bb\u548c\u4ea4\u4e92\u3002Unix\u8fdb\u7a0b\u4e4b\u95f4\u7684\u8bb8\u591a\u4ea4\u4e92\u5f62\u5f0f\u90fd\u662f\u901a\u8fc7\u6587\u4ef6\u63cf\u8ff0\u7b26\u5b9e\u73b0\u7684\u5728\u673a\u5668\u6a21\u5f0f\u4e0b\u6267\u884c\u7684\u6307\u4ee4\u5177\u6709\u5b8c\u5168\u7279\u6743,\u673a\u5668\u6a21\u5f0f\u4e3b\u8981\u7528\u4e8e\u914d\u7f6e\u8ba1\u7b97\u673a\u5728\u7ba1\u7406\u6a21\u5f0f\u4e0b\uff0cCPU\u88ab\u5141\u8bb8\u6267\u884c\u7279\u6743\u6307\u4ee4\u5e94\u7528\u7a0b\u5e8f\u53ea\u80fd\u6267\u884c\u7528\u6237\u6a21\u5f0f\u7684\u6307\u4ee4\uff08\u4f8b\u5982\uff0c\u6570\u5b57\u76f8\u52a0\u7b49\uff09\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u5904\u4e8e\u7ba1\u7406\u6a21\u5f0f\u4e0b\u7684\u8f6f\u4ef6\u53ef\u4ee5\u6267\u884c\u7279\u6743\u6307\u4ee4\uff0c\u5e76\u88ab\u79f0\u4e3a\u5728\u4e2d\u8fd0\u884c\u3002\u5728\u5185\u6838\u7a7a\u95f4\uff08\u6216\u7ba1\u7406\u6a21\u5f0f\uff09\u4e2d\u8fd0\u884c\u7684\u8f6f\u4ef6\u88ab\u79f0\u4e3a\u5185\u6838\u3002_\u5b9e\u9a8c2:system calls","og_url":"https:\/\/www.wsisp.com\/helps\/31533.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-21T07:06:19+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250421070609-6805ee61a338b.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/31533.html","url":"https:\/\/www.wsisp.com\/helps\/31533.html","name":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-21T07:06:19+00:00","dateModified":"2025-04-21T07:06:19+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/31533.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/31533.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/31533.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8cLab 2:System calls(MIT 6.S081 FALL 2020)"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/31533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=31533"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/31533\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/31526"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=31533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=31533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=31533"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=31533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}