{"id":12865,"date":"2025-04-18T19:56:27","date_gmt":"2025-04-18T11:56:27","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12865.html"},"modified":"2025-04-18T19:56:27","modified_gmt":"2025-04-18T11:56:27","slug":"%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f-%ef%bc%9a%e8%bf%9b%e7%a8%8b%e6%a6%82%e5%bf%b5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12865.html","title":{"rendered":"\u64cd\u4f5c\u7cfb\u7edf \uff1a\u8fdb\u7a0b\u6982\u5ff5"},"content":{"rendered":"<h2>\u64cd\u4f5c\u7cfb\u7edf &#xff1a;\u8fdb\u7a0b\u6982\u5ff5<\/h2>\n<h3>\u5f15\u8a00<\/h3>\n<p>\u7406\u89e3\u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0d\u4ec5\u6709\u52a9\u4e8e\u6211\u4eec\u638c\u63e1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5de5\u4f5c\u539f\u7406&#xff0c;\u8fd8\u80fd\u4e3a\u540e\u7eed\u5b66\u4e60\u591a\u4efb\u52a1\u5904\u7406\u3001\u5e76\u53d1\u7f16\u7a0b\u3001\u5185\u5b58\u7ba1\u7406\u7b49\u9ad8\u7ea7\u4e3b\u9898\u5960\u5b9a\u575a\u5b9e\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u7684\u65b9\u65b9\u9762\u9762&#xff0c;\u5305\u62ec\u5176\u57fa\u672c\u6982\u5ff5\u3001\u72b6\u6001\u7ba1\u7406\u3001\u4f18\u5148\u7ea7\u8c03\u5ea6\u3001\u5730\u5740\u7a7a\u95f4\u7b49\u6838\u5fc3\u5185\u5bb9&#xff0c;\u5e76\u7ed3\u5408\u5b9e\u9645\u793a\u4f8b\u548c\u4ee3\u7801\u5206\u6790&#xff0c;\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u5b8c\u6574\u7684\u77e5\u8bc6\u4f53\u7cfb\u3002<\/p>\n<hr \/>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\u64cd\u4f5c\u7cfb\u7edf &#xff1a;\u8fdb\u7a0b\u6982\u5ff5<\/li>\n<li>\n<ul>\n<li>\u5f15\u8a00<\/li>\n<li>1. \u51af\u8bfa\u4f9d\u66fc\u4f53\u7cfb\u7ed3\u6784<\/li>\n<li>2. \u64cd\u4f5c\u7cfb\u7edf\u6982\u5ff5\u53ca\u5b9a\u4f4d<\/li>\n<li>3. \u8fdb\u7a0b<\/li>\n<li>\n<ul>\n<li>3.1 \u8fdb\u7a0b\u7684\u57fa\u672c\u6982\u5ff5\u4e0e\u64cd\u4f5c<\/li>\n<li>3.2 \u8fdb\u7a0b\u7684\u72b6\u6001<\/li>\n<li>3.3 \u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7<\/li>\n<li>3.4 \u8fdb\u7a0b\u7684\u5207\u6362<\/li>\n<\/ul>\n<\/li>\n<li>4. \u73af\u5883\u53d8\u91cf<\/li>\n<li>\n<ul>\n<li>4.1 \u57fa\u672c\u6982\u5ff5<\/li>\n<li>4.2 \u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf<\/li>\n<li>4.3 \u5173\u4e8e\u73af\u5883\u53d8\u91cf\u7684\u547d\u4ee4<\/li>\n<li>4.4 \u901a\u8fc7\u4ee3\u7801\u83b7\u53d6\u73af\u5883\u53d8\u91cf<\/li>\n<li>4.5 bash\u7684\u4e24\u5f20\u8868<\/li>\n<\/ul>\n<\/li>\n<li>5. \u7a0b\u5e8f\u5730\u5740\u7a7a\u95f4<\/li>\n<li>\n<ul>\n<li>5.1 \u865a\u62df\u5730\u5740<\/li>\n<li>5.2 \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4&#xff08;\u91cd\u8981&#xff09;<\/li>\n<li>5.3 \u865a\u62df\u5185\u5b58\u7ba1\u7406\u7b2c\u4e00\u8bb2<\/li>\n<li>5.4 \u4e3a\u4ec0\u4e48\u8981\u6709\u865a\u62df\u5185\u5b58\u7a7a\u95f4<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>1. \u51af\u8bfa\u4f9d\u66fc\u4f53\u7cfb\u7ed3\u6784<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115622-68023de65c66e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5173\u4e8e\u51af\u8bfa\u4f9d\u66fc\u5fc5\u987b\u8981\u5f3a\u8c03\u7684\u51e0\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u8fd9\u91cc\u7684\u5b58\u50a8\u5668\u6307\u7684\u662f\u5185\u5b58\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u8003\u8651\u7f13\u5b58\u7684\u60c5\u51b5&#xff0c;\u8fd9\u91cc\u7684CPU\u80fd\u4e14\u53ea\u80fd\u5bf9\u5185\u5b58\u8fdb\u884c\u8bfb\u5199&#xff0c;\u4e0d\u80fd\u8bbf\u95ee\u5916\u8bbe&#xff08;\u8f93\u5165\u6216\u8f93\u51fa\u8bbe\u5907&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5916\u8bbe&#xff08;\u8f93\u5165\u6216\u8f93\u51fa\u8bbe\u5907&#xff09;\u8981\u8f93\u5165\u6216\u8005\u8f93\u51fa\u6570\u636e&#xff0c;\u4e5f\u53ea\u80fd\u5199\u5165\u5185\u5b58\u6216\u8005\u4ece\u5185\u5b58\u4e2d\u8bfb\u53d6\u3002<\/p>\n<\/li>\n<li>\n<p>\u603b\u7ed3&#xff1a;\u6240\u6709\u8bbe\u5907\u90fd\u53ea\u80fd\u76f4\u63a5\u548c\u5185\u5b58\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n<\/li>\n<li>\n<p>\u8f6f\u4ef6\u8fd0\u884c&#xff0c;\u5fc5\u987b\u5148\u52a0\u8f7d&#xff08;CPU\u6267\u884c\u52a0\u8f7d\u5230\u7684\u4ee3\u7801&#xff0c;\u8bbf\u95ee\u52a0\u8f7d\u5230\u7684\u6570\u636e&#xff09;&#xff0c;\u800c\u6570\u636e\u662f\u4ece\u4e00\u4e2a\u8bbe\u5907\u201c\u62f7\u8d1d\u201d\u5230\u53e6\u4e00\u4e2a\u8bbe\u5907\u7684\u3002\u56e0\u6b64\u4f53\u7cfb\u7ed3\u6784\u7684\u6548\u7387\u662f\u7531\u8bbe\u5907\u7684\u201c\u62f7\u8d1d\u201d\u6548\u7387\u51b3\u5b9a\u7684\u3002<\/p>\n<\/li>\n<li>\n<p>\u7a0b\u5e8f\u8fd0\u884c\u4e4b\u524d&#xff0c;\u5728\u78c1\u76d8\u4e2d\u52a0\u8f7d\u6587\u4ef6\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>2. \u64cd\u4f5c\u7cfb\u7edf\u6982\u5ff5\u53ca\u5b9a\u4f4d<\/h3>\n<ul>\n<li>\u6982\u5ff5<\/li>\n<\/ul>\n<p>\u64cd\u4f5c\u7cfb\u7edf\u662f\u4efb\u4f55\u8ba1\u7b97\u673a\u7cfb\u7edf\u90fd\u5305\u542b\u7684\u57fa\u672c\u7a0b\u5e8f\u96c6\u5408&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u662f\u4e00\u6b3e\u8fdb\u884c\u8f6f\u786c\u4ef6\u7ba1\u7406\u7684\u8f6f\u4ef6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115622-68023de683296.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u8bbe\u8ba1OS\u7684\u76ee\u7684<\/li>\n<\/ul>\n<p>\u5bf9\u4e0a&#xff0c;\u4e3a\u7528\u6237\u7a0b\u5e8f\u63d0\u4f9b\u4e00\u4e2a\u826f\u597d\u7684\u6267\u884c\u73af\u5883\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115622-68023de6c1079.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u5bf9\u4e0b&#xff0c;\u4e0e\u786c\u4ef6\u4ea4\u4e92&#xff0c;\u7ba1\u7406\u6240\u6709\u7684\u8f6f\u786c\u4ef6\u8d44\u6e90&#xff08;\u624b\u6bb5&#xff09;<\/p>\n<p>\u5c0f\u77e5\u8bc6&#xff1a;<\/p>\n<ul>\n<li>\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u4f7f\u7528\u7cfb\u7edf\u8c03\u7528&#xff0c;\u800c\u7cfb\u7edf\u8c03\u7528\u5176\u5b9e\u5c31\u662f\u7cfb\u7edf\u63d0\u4f9b\u7684\u51fd\u6570\u3002<\/li>\n<li>\u53ea\u8981\u7a0b\u5e8f\u8bbf\u95ee\u4e86\u786c\u4ef6&#xff0c;\u90a3\u4e48\u5b83\u5fc5\u987b\u8d2f\u7a7f\u6574\u4e2a\u8f6f\u786c\u4ef6\u4f53\u7cfb\u7ed3\u6784\u3002<\/li>\n<li>\u6211\u4eec\u6240\u4e86\u89e3\u7684\u5e93\u5728\u5e95\u5c42\u5c01\u88c5\u4e86\u7cfb\u7edf\u8c03\u7528\u3002<\/li>\n<\/ul>\n<p>\u7ba1\u7406&#xff1a;<\/p>\n<p>\u7ba1\u7406\u8005\u548c\u88ab\u7ba1\u7406\u8005\u4e0d\u89c1\u9762&#xff0c;\u7ba1\u7406\u8005\u662f\u6839\u636e\u6709\u4e2d\u95f4\u5c42\u83b7\u53d6\u7684\u201c\u6570\u636e\u201d\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<p>\u7ba1\u7406\u65b9\u5f0f\u5c31\u662f\u201c\u5148\u63cf\u8ff0\u5728\u7ec4\u7ec7\u201d\u2014\u2014\u63cf\u8ff0\u88ab\u7ba1\u7406\u7684\u5bf9\u8c61&#xff0c;\u7ec4\u7ec7\u88ab\u7ba1\u7406\u5bf9\u8c61\u3002<\/p>\n<p>\u4e3e\u4f8b&#xff1a;\u6821\u957f\u7ba1\u7406\u5b66\u751f\u5c31\u53ef\u4ee5\u8f6c\u5316\u4e3a\u6821\u957f\u5bf9\u4e8eexecl\u8868\u683c\u4e2d\u6570\u636e\u7684\u7ba1\u7406\u3002<\/p>\n<ul>\n<li>\n<p>\u7cfb\u7edf\u8c03\u7528\u548c\u5e93\u51fd\u6570\u6982\u5ff5<\/p>\n<p>\u5728\u5f00\u53d1\u89d2\u5ea6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u5bf9\u5916\u4f1a\u8868\u73b0\u4e3a\u4e00\u4e2a\u6574\u4f53&#xff0c;\u4f46\u662f\u4f1a\u66b4\u9732\u81ea\u5df1\u7684\u90e8\u5206\u63a5\u53e3&#xff0c;\u4f9b\u4e0a\u5c42\u5f00\u53d1\u4f7f\u7528&#xff0c;\u8fd9\u90e8\u7531\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u7684\u63a5\u53e3&#xff0c;\u53eb\u505a\u7cfb\u7edf\u8c03\u7528\u3002\u53ef\u4ee5\u7406\u89e3\u4e3a\u64cd\u4f5c\u7cfb\u7edf\u8981\u5411\u4e0a\u63d0\u4f9b\u5bf9\u5e94\u7684\u670d\u52a1&#xff0c;\u4f46\u662f\u4e0d\u76f8\u4fe1\u4efb\u4f55\u7528\u6237\u3002<\/p>\n<p>\u7cfb\u7edf\u8c03\u7528\u5728\u4f7f\u7528\u4e0a&#xff0c;\u529f\u80fd\u6bd4\u8f83\u57fa\u7840&#xff0c;\u5bf9\u7528\u6237\u7684\u8981\u6c42\u76f8\u5bf9\u4e5f\u6bd4\u8f83\u9ad8&#xff0c;\u6240\u4ee5&#xff0c;\u6709\u5fc3\u7684\u5f00\u53d1\u8005\u53ef\u4ee5\u5bf9\u90e8\u5206\u7cfb\u7edf\u8c03\u7528\u8fdb\u884c\u9002\u5ea6\u5c01\u88c5&#xff0c;\u4ece\u800c\u5f62\u6210\u5e93&#xff0c;\u6709\u4e86\u5e93&#xff0c;\u5c31\u5f88\u6709\u5229\u4e8e\u66f4\u4e0a\u5c42\u7528\u6237\u6216\u8005\u5f00\u53d1\u8005\u8fdb\u884c\u4e8c\u6b21\u5f00\u53d1\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3. \u8fdb\u7a0b<\/h3>\n<h4>3.1 \u8fdb\u7a0b\u7684\u57fa\u672c\u6982\u5ff5\u4e0e\u64cd\u4f5c<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de700f64.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\n<p>test_struct<\/p>\n<ul>\n<li>\n<p>\u6807\u793a\u7b26: \u63cf\u8ff0\u672c\u8fdb\u7a0b\u7684\u552f\u4e00\u6807\u793a\u7b26&#xff0c;\u7528\u6765\u533a\u522b\u5176\u4ed6\u8fdb\u7a0b\u3002&#xff08;pid&#xff09;<\/p>\n<\/li>\n<li>\n<p>\u72b6\u6001: \u4efb\u52a1\u72b6\u6001&#xff0c;\u9000\u51fa\u4ee3\u7801&#xff0c;\u9000\u51fa\u4fe1\u53f7\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f18\u5148\u7ea7: \u76f8\u5bf9\u4e8e\u5176\u4ed6\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7\u3002<\/p>\n<\/li>\n<li>\n<p>\u7a0b\u5e8f\u8ba1\u6570\u5668: \u7a0b\u5e8f\u4e2d\u5373\u5c06\u88ab\u6267\u884c\u7684\u4e0b\u4e00\u6761\u6307\u4ee4\u7684\u5730\u5740\u3002<\/p>\n<\/li>\n<li>\n<p>\u5185\u5b58\u6307\u9488: \u5305\u62ec\u7a0b\u5e8f\u4ee3\u7801\u548c\u8fdb\u7a0b\u76f8\u5173\u6570\u636e\u7684\u6307\u9488&#xff0c;\u8fd8\u6709\u548c\u5176\u4ed6\u8fdb\u7a0b\u5171\u4eab\u7684\u5185\u5b58\u5757\u7684\u6307\u9488<\/p>\n<\/li>\n<li>\n<p>\u4e0a\u4e0b\u6587\u6570\u636e: \u8fdb\u7a0b\u6267\u884c\u65f6\u5904\u7406\u5668\u7684\u5bc4\u5b58\u5668\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p>I&#xff0f;O\u72b6\u6001\u4fe1\u606f: \u5305\u62ec\u663e\u793a\u7684I\/O\u8bf7\u6c42,\u5206\u914d\u7ed9\u8fdb\u7a0b\u7684I&#xff0f;O\u8bbe\u5907\u548c\u88ab\u8fdb\u7a0b\u4f7f\u7528\u7684\u6587\u4ef6\u5217\u8868\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bb0\u8d26\u4fe1\u606f: \u53ef\u80fd\u5305\u62ec\u5904\u7406\u5668\u65f6\u95f4\u603b\u548c&#xff0c;\u4f7f\u7528\u7684\u65f6\u949f\u6570\u603b\u548c&#xff0c;\u65f6\u95f4\u9650\u5236&#xff0c;\u8bb0\u8d26\u53f7\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u5176\u4ed6\u4fe1\u606f<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u8fdb\u7a0b\u7684\u7ec4\u7ec7\u5f62\u5f0f<\/p>\n<p>\u5728\u5185\u6838\u6e90\u4ee3\u7801\u4e2d\u6211\u4eec\u4ee5\u53ef\u4ee5\u770b\u5230&#xff0c;\u6240\u6709\u8fd0\u884c\u5728\u7cfb\u7edf\u91cc\u7684\u8fdb\u7a0b\u90fd\u662f\u4ee5test_struct\u94fe\u8868\u7684\u5f62\u5f0f\u5b58\u5728\u5185\u6838\u91cc\u7684\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de72c7ed.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u8fdb\u7a0b<\/p>\n<li>\n<p>\u8fdb\u7a0b\u7684\u4fe1\u606f\u53ef\u4ee5\u901a\u8fc7\/proc\u7cfb\u7edf\u6587\u4ef6\u5939\u67e5\u770b\u3002\u5982&#xff1a;\u8981\u83b7\u53d6PID\u4e3a21381\u7684\u8fdb\u7a0b\u4fe1\u606f&#xff0c;\u4f60\u9700\u8981\u67e5\u770b \/proc\/21381 \u8fd9\u4e2a\u6587\u4ef6\u5939\u3002<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de753510.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u8fdb\u7a0b\u4fe1\u606f\u4e2d\u6709\u4e00\u4e2acwd(current work dir)&#xff0c;\u5176\u4f5c\u7528\u662f\u8fdb\u7a0b\u4f1a\u8bb0\u5f55\u4e0b\u6765\u81ea\u5df1\u7684\u5f53\u524d\u8def\u5f84&#xff0c;\u8fd9\u4e5f\u5c31\u5370\u8bc1\u4e86\u4e3a\u4ec0\u4e48\u6211\u4eec\u5728C\u8bed\u8a00\u4e2dfopen\u65f6&#xff0c;\u65e2\u53ef\u4ee5\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84&#xff0c;\u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u6587\u4ef6\u540d\u3002<\/p>\n<\/li>\n<li>\n<p>\u5927\u591a\u6570\u8fdb\u7a0b\u4fe1\u606f\u540c\u6837\u4e5f\u53ef\u4ee5\u4f7f\u7528top,ps\u8fd9\u4e9b\u7528\u6237\u7ea7\u5de5\u5177\u6765\u83b7\u53d6\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de766239.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>ps\u7684\u53c2\u6570\u9009\u9879&#xff1a;<\/p>\n<ul>\n<li>a&#xff1a;\u663e\u2f70\u2f00\u4e2a\u7ec8\u7aef\u6240\u6709\u7684\u8fdb\u7a0b&#xff0c;\u5305\u62ec\u5176\u4ed6\u2f64\u2f3e\u7684\u8fdb\u7a0b\u3002<\/li>\n<li>x&#xff1a;\u663e\u2f70\u6ca1\u6709\u63a7\u5236\u7ec8\u7aef\u7684\u8fdb\u7a0b&#xff0c;\u4f8b\u5982\u540e\u53f0\u8fd0\u884c\u7684\u5b88\u62a4\u8fdb\u7a0b\u3002<\/li>\n<li>j&#xff1a;\u663e\u2f70\u8fdb\u7a0b\u5f52\u5c5e\u7684\u8fdb\u7a0b\u7ec4ID\u3001\u4f1a\u8bddID\u3001\u7236\u8fdb\u7a0bID&#xff0c;\u4ee5\u53ca\u4e0e\u4f5c\u4e1a\u63a7\u5236\u76f8\u5173\u7684\u4fe1\u606f\u3002<\/li>\n<li>u&#xff1a;\u4ee5\u2f64\u2f3e\u4e3a\u4e2d\u5fc3\u7684\u683c\u5f0f\u663e\u793a\u8fdb\u7a0b\u4fe1\u606f&#xff0c;\u63d0\u4f9b\u8fdb\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f&#xff0c;\u5982\u2f64\u2f3e\u3001CPU\u548c\u5185\u5b58\u4f7f\u2f64\u60c5\u51b5\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\u83b7\u53d6\u8fdb\u7a0b\u6807\u8bc6\u7b26<\/p>\n<p>\u8fdb\u7a0bid&#xff1a;pid&#xff1b;\u7236\u8fdb\u7a0bid&#xff1a;ppid<\/p>\n<p> <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/types.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;pid: %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;ppid: %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getppid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>\n <\/li>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>3.2 \u8fdb\u7a0b\u7684\u72b6\u6001<\/h4>\n<ul>\n<li>\n<p>kernel\u6e90\u4ee3\u7801\u4e2d\u7684\u8fdb\u7a0b\u72b6\u6001<\/p>\n<p>   <span class=\"token comment\">\/*<br \/>\n*The task state array is a strange &#034;bitmap&#034; of<br \/>\n*reasons to sleep. Thus &#034;running&#034; is zero, and<br \/>\n*you can test for combinations of others with<br \/>\n*simple bit tests.<br \/>\n*\/<\/span><br \/>\n<span class=\"token keyword\">static<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token keyword\">const<\/span> task_state_array<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token string\">&#034;R (running)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*0 *\/<\/span><br \/>\n<span class=\"token string\">&#034;S (sleeping)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*1 *\/<\/span><span class=\"token comment\">\/\/\u53ef\u4e2d\u65ad\u4f11\u7720&#xff0c;\u6d45\u7761\u7720<\/span><br \/>\n<span class=\"token string\">&#034;D (disk sleep)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*2 *\/<\/span><span class=\"token comment\">\/\/\u4e0d\u53ef\u4e2d\u65ad\u7761\u7720&#xff0c;\u6df1\u5ea6\u7761\u7720&#xff08;\u78c1\u76d8&#xff09;<\/span><br \/>\n<span class=\"token string\">&#034;T (stopped)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*4 *\/<\/span><span class=\"token comment\">\/\/\u8fdb\u7a0b\u51fa\u9519&#xff0c;OS\u5f3a\u5236\u6682\u505c<\/span><br \/>\n<span class=\"token string\">&#034;t (tracing stop)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*8 *\/<\/span><span class=\"token comment\">\/\/\u88abdebug\u65ad\u70b9&#xff0c;\u5c06\u8fdb\u7a0b\u6682\u505c<\/span><br \/>\n<span class=\"token string\">&#034;X (dead)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*16 *\/<\/span><span class=\"token comment\">\/\/\u91ca\u653ePCB\u7684\u8fdb\u7a0b<\/span><br \/>\n<span class=\"token string\">&#034;Z (zombie)&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\">\/*32 *\/<\/span><span class=\"token comment\">\/\/\u4e3a\u4e86\u83b7\u53d6\u9000\u51fa\u4fe1\u606f&#xff0c;\u800c\u672a\u91ca\u653ePCB\u7684\u8fdb\u7a0b<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<ul>\n<li>R\u8fd0\u884c\u72b6\u6001&#xff08;running&#xff09;: \u5e76\u4e0d\u610f\u5473\u7740\u8fdb\u7a0b\u4e00\u5b9a\u5728\u8fd0\u884c\u4e2d&#xff0c;\u5b83\u8868\u660e\u8fdb\u7a0b\u8981\u4e48\u662f\u5728\u8fd0\u884c\u4e2d\u8981\u4e48\u5728\u8fd0\u884c\u961f\u5217\u91cc\u3002<\/li>\n<li>S\u7761\u7720\u72b6\u6001&#xff08;sleeping): \u610f\u5473\u7740\u8fdb\u7a0b\u5728\u7b49\u5f85\u4e8b\u4ef6\u5b8c\u6210&#xff08;\u8fd9\u91cc\u7684\u7761\u7720\u6709\u65f6\u5019\u4e5f\u53eb\u505a\u53ef\u4e2d\u65ad\u7761\u7720&#xff08;interruptible sleep&#xff09;&#xff09;\u3002<\/li>\n<li>D\u78c1\u76d8\u4f11\u7720\u72b6\u6001&#xff08;Disk sleep&#xff09;\u6709\u65f6\u5019\u4e5f\u53eb\u4e0d\u53ef\u4e2d\u65ad\u7761\u7720\u72b6\u6001&#xff08;uninterruptible sleep&#xff09;&#xff0c;\u5728\u8fd9\u4e2a\u72b6\u6001\u7684\u8fdb\u7a0b\u901a\u5e38\u4f1a\u7b49\u5f85IO\u7684\u7ed3\u675f\u3002<\/li>\n<li>T\u505c\u6b62\u72b6\u6001&#xff08;stopped&#xff09;&#xff1a; \u53ef\u4ee5\u901a\u8fc7\u53d1\u9001 SIGSTOP \u4fe1\u53f7\u7ed9\u8fdb\u7a0b\u6765\u505c\u6b62&#xff08;T&#xff09;\u8fdb\u7a0b\u3002\u8fd9\u4e2a\u88ab\u6682\u505c\u7684\u8fdb\u7a0b\u53ef\u4ee5\u901a\u8fc7\u53d1\u9001 SIGCONT \u4fe1\u53f7\u8ba9\u8fdb\u7a0b\u7ee7\u7eed\u8fd0\u884c\u3002<\/li>\n<li>X\u6b7b\u4ea1\u72b6\u6001&#xff08;dead&#xff09;&#xff1a;\u8fd9\u4e2a\u72b6\u6001\u53ea\u662f\u4e00\u4e2a\u8fd4\u56de\u72b6\u6001&#xff0c;\u4f60\u4e0d\u4f1a\u5728\u4efb\u52a1\u5217\u8868\u91cc\u770b\u5230\u8fd9\u4e2a\u72b6\u6001\u3002<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de77c591.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd0\u884c&#xff1a;\u8fdb\u7a0b\u5728\u8c03\u5ea6\u961f\u5217\u4e2d&#xff0c;\u8fdb\u7a0b\u7684\u72b6\u6001\u90fd\u662frunning\u3002<\/p>\n<p>\u963b\u585e&#xff1a;\u7b49\u5f85\u67d0\u79cd\u8bbe\u5907\u6216\u8005\u8d44\u6e90\u5c31\u7eea&#xff08;\u952e\u76d8&#xff0c;\u663e\u793a\u5668&#xff0c;\u7f51\u5361&#xff0c;\u78c1\u76d8&#xff0c;\u6444\u50cf\u5934&#xff0c;\u8bdd\u7b52\u2026&#xff09;\u3002<\/p>\n<p>\u8fdb\u7a0b\u72b6\u6001\u7684\u53d8\u5316\u8868\u73b0\u4e4b\u4e00&#xff0c;\u5c31\u662f\u8981\u5728\u4e0d\u540c\u7684\u961f\u5217\u4e2d\u8fdb\u884c\u6d41\u52a8&#xff0c;\u672c\u8d28\u90fd\u662f\u6570\u636e\u7ed3\u6784\u7684\u589e\u5220\u67e5\u6539\u3002<\/p>\n<\/li>\n<li>\n<p>\u50f5\u5c38\u8fdb\u7a0b<\/p>\n<p>\u50f5\u6b7b\u72b6\u6001&#xff08;Zombies&#xff09;\u662f\u4e00\u4e2a\u6bd4\u8f83\u7279\u6b8a\u7684\u72b6\u6001\u3002\u5f53\u8fdb\u7a0b\u9000\u51fa\u5e76\u4e14\u7236\u8fdb\u7a0b\u6ca1\u6709\u8bfb\u53d6\u5230\u5b50\u8fdb\u7a0b\u9000\u51fa\u7684\u8fd4\u56de\u4ee3\u7801\u65f6\u5c31\u4f1a\u4ea7\u751f\u50f5\u5c38\u8fdb\u7a0b\u3002<\/p>\n<p>\u50f5\u6b7b\u8fdb\u7a0b\u4f1a\u4ee5\u7ec8\u6b62\u72b6\u6001\u4fdd\u6301\u5728\u8fdb\u7a0b\u8868\u4e2d&#xff0c;\u5e76\u4e14\u4f1a\u4e00\u76f4\u5728\u7b49\u5f85\u7236\u8fdb\u7a0b\u8bfb\u53d6\u9000\u51fa\u72b6\u6001\u4ee3\u7801\u3002<\/p>\n<p>\u6240\u4ee5&#xff0c;\u53ea\u8981\u5b50\u8fdb\u7a0b\u9000\u51fa&#xff0c;\u7236\u8fdb\u7a0b\u8fd8\u5728\u8fd0\u884c&#xff0c;\u4f46\u7236\u8fdb\u7a0b\u6ca1\u6709\u8bfb\u53d6\u5b50\u8fdb\u7a0b\u72b6\u6001&#xff0c;\u5b50\u8fdb\u7a0b\u8fdb\u5165Z\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p>\u50f5\u5c38\u8fdb\u7a0b\u7684\u5371\u5bb3\u2014\u2014\u5185\u5b58\u6cc4\u9732<\/p>\n<p>\u8fdb\u7a0b\u7684\u9000\u51fa\u72b6\u6001\u5fc5\u987b\u88ab\u7ef4\u6301\u4e0b\u53bb&#xff0c;\u56e0\u4e3a\u4ed6\u8981\u544a\u8bc9\u7236\u8fdb\u7a0b&#xff0c;\u4f60\u4ea4\u7ed9\u6211\u7684\u4efb\u52a1&#xff0c;\u6211\u529e\u7684\u600e\u4e48\u6837\u4e86\u3002\u53ef\u7236\u8fdb\u7a0b\u5982\u679c\u4e00\u76f4\u4e0d\u8bfb\u53d6&#xff0c;\u5b50\u8fdb\u7a0b\u5c31\u4f1a\u4e00\u76f4\u5904\u4e8eZ\u72b6\u6001\u3002<\/p>\n<p>\u7ef4\u62a4\u9000\u51fa\u72b6\u6001\u672c\u8eab\u5c31\u662f\u8981\u7528\u6570\u636e\u7ef4\u62a4&#xff0c;\u4e5f\u5c5e\u4e8e\u8fdb\u7a0b\u57fa\u672c\u4fe1\u606f&#xff0c;\u6240\u4ee5\u4fdd\u5b58\u5728task_struct(PCB)\u4e2d&#xff0c;\u6362\u53e5\u8bdd\u8bf4&#xff0c;Z\u72b6\u6001\u4e00\u76f4\u4e0d\u9000\u51fa&#xff0c;PCB\u5c31\u4e00\u76f4\u90fd\u8981\u7ef4\u62a4\u3002<\/p>\n<p>\u5982\u679c\u4e00\u4e2a\u7236\u8fdb\u7a0b\u521b\u5efa\u4e86\u5f88\u591a\u5b50\u8fdb\u7a0b&#xff0c;\u5c31\u662f\u4e0d\u56de\u6536&#xff0c;\u5c31\u4f1a\u9020\u6210\u5185\u5b58\u8d44\u6e90\u7684\u6d6a\u8d39\u3002\u56e0\u4e3a\u6570\u636e\u7ed3\u6784\u5bf9\u8c61\u672c\u8eab\u5c31\u8981\u5360\u7528\u5185\u5b58\u3002<\/p>\n<\/li>\n<li>\n<p>\u77e5\u8bc6\u70b9<\/p>\n<p>\u8fdb\u7a0b\u9000\u51fa\u4e86&#xff0c;\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u5c31\u4e0d\u5b58\u5728\u4e86\u3002<\/p>\n<p>\u5e38\u9a7b\u5185\u5b58\u7684\u8fdb\u7a0b\u6240\u5177\u6709\u7684\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898&#xff0c;\u662f\u6bd4\u8f83\u9ebb\u70e6\u7684\u3002<\/p>\n<p>\u5185\u6838\u7ed3\u6784\u7533\u8bf7\u4e2d&#xff0c;\u5b58\u5728\u6570\u636e\u7ed3\u6784\u5bf9\u8c61\u7684\u7f13\u5b58&#xff0c;\u662f\u6307\u8fdb\u7a0b\u7ed3\u675f\u540e\u7684PCB\u4ece\u8c03\u5ea6\u961f\u5217\u8f6c\u4e3a\u5783\u573e\u961f\u5217\u4e2d&#xff0c;\u7b49\u5f85\u4e0b\u4e00\u6b21\u7684\u5e9f\u7269\u5229\u7528\u3002<\/p>\n<\/li>\n<li>\n<p>\u5b64\u513f\u8fdb\u7a0b<\/p>\n<p>\u5728\u7236\u5b50\u8fdb\u7a0b\u5173\u7cfb\u4e2d&#xff0c;\u5982\u679c\u7236\u8fdb\u7a0b\u5148\u9000\u51fa&#xff0c;\u6b64\u65f6\u5b50\u8fdb\u7a0b\u5c31\u88ab\u79f0\u4e3a\u201c\u5b64\u513f\u8fdb\u7a0b\u201d\u3002<\/p>\n<p>\u5b64\u513f\u8fdb\u7a0b\u4f1a\u88ab1\u53f7\u8fdb\u7a0b&#xff08;\u6682\u4e14\u7406\u89e3\u4e3a\u64cd\u4f5c\u7cfb\u7edf&#xff09;\u9886\u517b&#xff0c;\u9632\u6b62\u5b64\u513f\u8fdb\u7a0b\u8fdb\u4e00\u6b65\u53d8\u6210\u50f5\u5c38\u8fdb\u7a0b\u4ece\u800c\u5bfc\u81f4\u5185\u5b58\u6cc4\u9732\u3002<\/p>\n<p>\u88ab\u9886\u517b\u7684\u5b64\u513f\u8fdb\u7a0b\u4f1a\u53d8\u6210\u540e\u53f0\u8fdb\u7a0b&#xff0c;\u56e0\u6b64\u4f7f\u7528Ctrl &#043; c\u662f\u65e0\u6cd5\u7ed3\u675f\u8fdb\u7a0b\u7684&#xff0c;\u4e14\u540e\u53f0\u8fdb\u7a0b\u53ef\u4ee5\u5411\u524d\u53f0\u6253\u5370\u6d88\u606f\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>3.3 \u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7<\/h4>\n<ul>\n<li>\n<p>\u6982\u5ff5<\/p>\n<p>cpu\u8d44\u6e90\u5206\u914d\u7684\u5148\u540e\u987a\u5e8f&#xff0c;\u5c31\u662f\u6307\u8fdb\u7a0b\u7684\u4f18\u5148\u6743(priority)&#xff0c;\u4f18\u5148\u6743\u53ef\u4ee5\u89e3\u51b3\u76ee\u6807\u8d44\u6e90\u77ed\u7f3a\u9700\u8981\u5408\u7406\u5206\u914d\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4f18\u5148\u6743\u9ad8\u7684\u8fdb\u7a0b\u6709\u4f18\u5148\u6267\u884c\u6743\u5229\u3002\u914d\u7f6e\u8fdb\u7a0b\u4f18\u5148\u6743\u5bf9\u591a\u4efb\u52a1\u73af\u5883\u7684linux\u5f88\u6709\u7528&#xff0c;\u53ef\u4ee5\u6539\u5584\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n<p>\u4f18\u5148\u6743\u4e5f\u662f\u4e00\u79cd\u503c&#xff0c;\u503c\u8d8a\u4f4e&#xff0c;\u4f18\u5148\u7ea7\u8d8a\u9ad8\u3002<\/p>\n<p>\u8fd8\u53ef\u4ee5\u628a\u8fdb\u7a0b\u8fd0\u884c\u5230\u6307\u5b9a\u7684CPU\u4e0a&#xff0c;\u8fd9\u6837\u4e00\u6765&#xff0c;\u628a\u4e0d\u91cd\u8981\u7684\u8fdb\u7a0b\u5b89\u6392\u5230\u67d0\u4e2aCPU&#xff0c;\u53ef\u4ee5\u5927\u5927\u6539\u5584\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u3002<\/p>\n<p>Linux\u662f\u4e00\u79cd\u57fa\u4e8e\u65f6\u95f4\u7247\u7684\u5206\u65f6\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u8003\u8651\u516c\u5e73\u6027&#xff0c;\u4f18\u5148\u7ea7\u53ef\u80fd\u53d8\u5316&#xff0c;\u4f46\u662f\u53d8\u5316\u7684\u5e45\u5ea6\u4e0d\u80fd\u592a\u5927\u3002<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b\u7cfb\u7edf\u8fdb\u7a0b<\/p>\n<p>\u5728Linux\u7cfb\u7edf\u4e2d&#xff0c;\u7528ps -l\u67e5\u770b\u7cfb\u7edf\u8fdb\u7a0b\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de7a8b37.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>UID : \u4ee3\u8868\u6267\u884c\u8005\u7684\u8eab\u4efduser id&#xff0c;\u5728Linux\u4e2d\u8bbf\u95ee\u4efb\u4f55\u8d44\u6e90\u90fd\u662f\u8fdb\u7a0b\u8bbf\u95ee&#xff0c;\u8fdb\u7a0b\u5c31\u4ee3\u8868\u7528\u6237\u3002\u56e0\u6b64\u7cfb\u7edf\u901a\u8fc7\u6bd4\u8f83UID\u548c\u6587\u4ef6\u6240\u5c5eid&#xff0c;\u5c31\u80fd\u77e5\u9053\u7528\u6237\u662f\u62e5\u6709\u8005\u8fd8\u662f\u6240\u5c5e\u7ec4\u4ea6\u6216\u662fother\u3002<\/li>\n<li>PID : \u4ee3\u8868\u8fd9\u4e2a\u8fdb\u7a0b\u7684\u4ee3\u53f7\u3002<\/li>\n<li>PPID &#xff1a;\u4ee3\u8868\u8fd9\u4e2a\u8fdb\u7a0b\u662f\u7531\u54ea\u4e2a\u8fdb\u7a0b\u53d1\u5c55\u884d\u751f\u800c\u6765\u7684&#xff0c;\u4ea6\u5373\u7236\u8fdb\u7a0b\u7684\u4ee3\u53f7\u3002<\/li>\n<li>PRI &#xff1a;\u4ee3\u8868\u8fd9\u4e2a\u8fdb\u7a0b\u53ef\u88ab\u6267\u884c\u7684\u4f18\u5148\u7ea7&#xff0c;\u5176\u503c\u8d8a\u5c0f\u8d8a\u65e9\u88ab\u6267\u884c\u3002&#xff08;\u9ed8\u8ba4\u503c\u4e3a80&#xff09;<\/li>\n<li>NI &#xff1a;\u4ee3\u8868\u8fd9\u4e2a\u8fdb\u7a0b\u7684nice\u503c&#xff0c;\u5176\u662f\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u4fee\u6b63\u6570\u503c&#xff08;\u7528\u6765\u66f4\u6539PRI\u7684&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>PRI &amp; NI<\/p>\n<p>\u8fdb\u7a0b\u7684\u771f\u5b9e\u4f18\u5148\u7ea7 &#061; PRI&#xff08;\u9ed8\u8ba4\u4e3a80&#xff09;&#043; NI<\/p>\n<p>\u4f18\u5148\u7ea7\u7684\u6781\u503c&#xff1a;\u5982\u679c\u4f18\u5148\u7ea7\u8bbe\u7f6e\u7684\u4e0d\u5408\u7406&#xff0c;\u4f1a\u5bfc\u81f4\u4f18\u5148\u7ea7\u4f4e\u7684\u8fdb\u7a0b&#xff0c;\u957f\u65f6\u95f4\u5f97\u4e0d\u5230CPU\u8d44\u6e90&#xff0c;\u8fdb\u800c\u5bfc\u81f4\u8fdb\u7a0b\u9965\u997f\u3002\u56e0\u6b64nice\u503c\u53ea\u80fd\u53d6\u5230[-20 , 19],\u90a3\u4e48\u8fdb\u7a0b\u7684\u4f18\u5148\u7ea7\u8303\u56f4\u5c31\u662f[60 , 99]\u517140\u4e2a\u7b49\u7ea7\u3002<\/p>\n<p>\u7528top\u547d\u4ee4\u66f4\u6539\u5df2\u7ecf\u5b58\u5728\u8fdb\u7a0b\u7684nice\u503c&#xff1a;\u8f93\u5165top-&gt;\u6309r-&gt;\u8f93\u5165\u8fdb\u7a0bPID-&gt;\u8f93\u5165\u8981\u4fee\u6539\u7684nice\u503c\u3002<\/p>\n<\/li>\n<li>\n<p>\u7ade\u4e89\u3001\u72ec\u7acb\u3001\u5e76\u884c\u3001\u5e76\u53d1<\/p>\n<p>\u7ade\u4e89\u6027: \u7cfb\u7edf\u8fdb\u7a0b\u6570\u76ee\u4f17\u591a&#xff0c;\u800cCPU\u8d44\u6e90\u53ea\u6709\u5c11\u91cf&#xff0c;\u751a\u81f31\u4e2a&#xff0c;\u6240\u4ee5\u8fdb\u7a0b\u4e4b\u95f4\u662f\u5177\u6709\u7ade\u4e89\u5c5e\u6027\u7684\u3002\u4e3a\u4e86\u9ad8\u6548\u5b8c\u6210\u4efb\u52a1&#xff0c;\u66f4\u5408\u7406\u7ade\u4e89\u76f8\u5173\u8d44\u6e90&#xff0c;\u4fbf\u5177\u6709\u4e86\u4f18\u5148\u7ea7\u3002<\/p>\n<p>\u72ec\u7acb\u6027: \u591a\u8fdb\u7a0b\u8fd0\u884c&#xff0c;\u9700\u8981\u72ec\u4eab\u5404\u79cd\u8d44\u6e90&#xff0c;\u591a\u8fdb\u7a0b\u8fd0\u884c\u671f\u95f4\u4e92\u4e0d\u5e72\u6270\u3002<\/p>\n<p>\u5e76\u884c: \u591a\u4e2a\u8fdb\u7a0b\u5728\u591a\u4e2aCPU\u4e0b\u5206\u522b&#xff0c;\u540c\u65f6\u8fdb\u884c\u8fd0\u884c&#xff0c;\u8fd9\u79f0\u4e4b\u4e3a\u5e76\u884c\u3002<\/p>\n<p>\u5e76\u53d1: \u591a\u4e2a\u8fdb\u7a0b\u5728\u4e00\u4e2aCPU\u4e0b\u91c7\u7528\u8fdb\u7a0b\u5207\u6362\u7684\u65b9\u5f0f&#xff0c;\u5728\u4e00\u6bb5\u65f6\u95f4\u4e4b\u5185&#xff0c;\u8ba9\u591a\u4e2a\u8fdb\u7a0b\u90fd\u5f97\u4ee5\u63a8\u8fdb&#xff0c;\u79f0\u4e4b\u4e3a\u5e76\u53d1\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de7bce2c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h4>3.4 \u8fdb\u7a0b\u7684\u5207\u6362<\/h4>\n<p>CPU\u4e0a\u4e0b\u6587\u5207\u6362&#xff1a;\u5176\u5b9e\u9645\u542b\u4e49\u662f\u4efb\u52a1\u5207\u6362, \u6216\u8005CPU\u5bc4\u5b58\u5668\u5207\u6362\u3002\u5f53\u591a\u4efb\u52a1\u5185\u6838\u51b3\u5b9a\u8fd0\u884c\u53e6\u5916\u7684\u4efb\u52a1\u65f6, \u5b83\u4fdd\u5b58\u6b63\u5728\u8fd0\u884c\u4efb\u52a1\u7684\u5f53\u524d\u72b6\u6001, \u4e5f\u5c31\u662fCPU\u5bc4\u5b58\u5668&#xff08;CPU\u5185\u90e8\u7684\u4e34\u65f6\u7a7a\u95f4&#xff09;\u4e2d\u7684\u5168\u90e8\u5185\u5bb9\u3002\u8fd9\u4e9b\u5185\u5bb9\u88ab\u4fdd\u5b58\u5728\u4efb\u52a1\u81ea\u5df1\u7684\u5806\u6808\u4e2d, \u5165\u6808\u5de5\u4f5c\u5b8c\u6210\u540e\u5c31\u628a\u4e0b\u4e00\u4e2a\u5c06\u8981\u8fd0\u884c\u7684\u4efb\u52a1\u7684\u5f53\u524d\u72b6\u51b5\u4ece\u8be5\u4efb\u52a1\u7684\u6808\u4e2d\u91cd\u65b0\u88c5\u2f0aCPU\u5bc4\u5b58\u5668,\u5e76\u5f00\u59cb\u4e0b\u2f00\u4e2a\u4efb\u52a1\u7684\u8fd0\u884c, \u8fd9\u2f00\u8fc7\u7a0b\u5c31\u662fcontext switch\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115623-68023de7d332d.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6b7b\u5faa\u73af\u8fdb\u7a0b\u4e0d\u4f1a\u4f7f\u7cfb\u7edf\u5d29\u6e83&#xff0c;\u56e0\u4e3a\u65f6\u95f4\u7247\u8fdb\u7a0b\u4e0d\u4f1a\u4e00\u76f4\u5360\u6709CPU\u53bb\u8fd0\u884c\u3002<\/p>\n<p>\u8fdb\u7a0b\u81ea\u5df1\u7684\u4e0a\u4e0b\u6587\u6570\u636e\u662f\u4fdd\u5b58\u5728test_struct\u4e2d\u7684TSS:\u4efb\u52a1\u72b6\u6001\u6bb5\u3002<\/p>\n<ul>\n<li>\n<p>Linux\u771f\u5b9e\u8c03\u5ea6\u7b97\u6cd5&#xff1a;O(1)\u8c03\u5ea6\u7b97\u6cd5<\/p>\n<ul>\n<li>\n<p>Linux2.6\u5185\u6838\u4e2d\u8fdb\u7a0b\u961f\u5217\u7684\u6570\u636e\u7ed3\u6784runqueue\u2014\u2014 \u4e00\u4e2aCPU\u62e5\u6709\u4e00\u4e2arunqueue<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115624-68023de800e60.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\n<p>\u65f6\u95f4\u7247\u8fd8\u6ca1\u6709\u7ed3\u675f\u7684\u6240\u6709\u8fdb\u7a0b\u90fd\u6309\u7167\u4f18\u5148\u7ea7\u653e\u5728\u6d3b\u52a8\u961f\u5217<\/p>\n<\/li>\n<li>\n<p>nr_active: \u8bb0\u5f55\u603b\u5171\u6709\u591a\u5c11\u4e2a\u8fd0\u884c\u72b6\u6001\u7684\u8fdb\u7a0b<\/p>\n<\/li>\n<li>\n<p>queue[140]: \u4e00\u4e2a\u5143\u7d20\u5c31\u662f\u4e00\u4e2a\u8fdb\u7a0b\u961f\u5217&#xff0c;\u76f8\u540c\u4f18\u5148\u7ea7\u7684\u8fdb\u7a0b\u6309\u7167FIFO\u89c4\u5219\u8fdb\u884c\u6392\u961f\u8c03\u5ea6,\u6240\u4ee5&#xff0c;\u6570\u7ec4\u4e0b\u6807\u5c31\u662f\u4f18\u5148\u7ea7&#xff01;[0,99]\u662f\u5b9e\u65f6\u4f18\u5148\u7ea7\u6211\u4eec\u4e0d\u9700\u8981\u5173\u5fc3&#xff0c;\u53ea\u9700\u5173\u6ce8[100,139]\u8fd940\u4e2a\u666e\u901a\u4f18\u5148\u7ea7\u5373\u53ef\u3002<\/p>\n<\/li>\n<li>\n<p>\u4ece\u8be5\u7ed3\u6784\u4e2d&#xff0c;\u9009\u62e9\u2f00\u4e2a\u6700\u5408\u9002\u7684\u8fdb\u7a0b&#xff0c;\u8fc7\u7a0b\u5982\u4e0b&#xff1a;<\/p>\n<li>\u4ece0\u4e0b\u8868\u5f00\u59cb\u904d\u5386queue[140]<\/li>\n<li>\u627e\u5230\u7b2c\u2f00\u4e2a\u975e\u7a7a\u961f\u5217&#xff0c;\u8be5\u961f\u5217\u5fc5\u5b9a\u4e3a\u4f18\u5148\u7ea7\u6700\u2fbc\u7684\u961f\u5217<\/li>\n<li>\u62ff\u5230\u9009\u4e2d\u961f\u5217\u7684\u7b2c\u2f00\u4e2a\u8fdb\u7a0b&#xff0c;\u5f00\u59cb\u8fd0\u884c&#xff0c;\u8c03\u5ea6\u5b8c\u6210&#xff01;<\/li>\n<\/li>\n<li>\n<p>bitmap[5]:\u904d\u5386queue[140]\u65f6\u95f4\u590d\u6742\u5ea6\u867d\u7136\u662f\u5e38\u6570\u4f46\u8fd8\u662f\u592a\u4f4e\u6548\u4e86&#xff0c;\u56e0\u6b64\u5f15\u5165bitmap[5]\u3002\u2f00\u5171140\u4e2a\u4f18\u5148\u7ea7&#xff0c;\u2f00\u5171140\u4e2a\u8fdb\u7a0b\u961f\u5217&#xff0c;\u4e3a\u4e86\u63d0\u2fbc\u67e5\u627e\u2fae\u7a7a\u961f\u5217\u7684\u6548\u7387&#xff0c;\u5c31\u53ef\u4ee5\u2f645*32\u4e2a\u6bd4\u7279\u4f4d\u8868\u793a\u961f\u5217\u662f\u5426\u4e3a\u7a7a&#xff0c;\u8fd9\u6837\u4fbf\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u67e5\u627e\u6548\u7387&#xff01;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115624-68023de821f7c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/li>\n<li>\n<p>\u8fc7\u671f\u8fdb\u7a0b\u7684queue[140]\u548c\u6d3b\u8dc3\u8fdb\u7a0b\u7ed3\u6784\u4e00\u6a21\u4e00\u6837&#xff0c;\u53ea\u4e0d\u8fc7\u8fc7\u671f\u961f\u5217\u4e0a\u653e\u7f6e\u7684\u8fdb\u7a0b\u90fd\u662f\u65f6\u95f4\u7247\u8017\u5c3d\u7684\u8fdb\u7a0b\u3002\u5f53\u6d3b\u52a8\u961f\u5217\u7684\u8fdb\u7a0b\u90fd\u88ab\u5904\u7406\u5b8c\u6bd5\u4e4b\u540e&#xff0c;\u5bf9\u8fc7\u671f\u961f\u5217\u7684\u8fdb\u7a0b\u8fdb\u884c\u65f6\u95f4\u7247\u91cd\u65b0\u8ba1\u7b97\u3002<\/p>\n<\/li>\n<li>\n<p>*active\u6307\u9488\u6c38\u8fdc\u6307\u5411\u6d3b\u52a8\u961f\u5217&#xff1b;*expired\u6307\u9488\u6c38\u8fdc\u6307\u5411\u8fc7\u671f\u961f\u5217&#xff1b;\u7531\u4e8e\u6d3b\u52a8\u961f\u5217\u4e0a\u7684\u8fdb\u7a0b\u56e0\u4e3a\u65f6\u95f4\u7247\u7684\u8017\u5c3d\u4f1a\u5728\u8fc7\u671f\u961f\u5217\u8d8a\u79ef\u8d8a\u591a&#xff0c;\u800c\u6d3b\u52a8\u961f\u5217\u7684\u8fdb\u7a0b\u4f1a\u8d8a\u6765\u8d8a\u5c11\u3002\u8fd9\u65f6\u5c31\u9700\u8981*active\u6307\u9488\u548c*expired\u6307\u9488\u4ea4\u6362\u4e00\u4e0b\u6307\u5411\u7684\u5185\u5bb9\u5373\u53ef\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u603b\u7ed3&#xff1a;\u5728\u7cfb\u7edf\u5f53\u4e2d\u67e5\u627e\u2f00\u4e2a\u6700\u5408\u9002\u8c03\u5ea6\u7684\u8fdb\u7a0b\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662f\u2f00\u4e2a\u5e38\u6570&#xff0c;\u4e0d\u968f\u7740\u8fdb\u7a0b\u589e\u591a\u800c\u5bfc\u81f4\u65f6\u95f4\u6210\u672c\u589e\u52a0&#xff0c;\u6211\u4eec\u79f0\u4e4b\u4e3a\u8fdb\u7a0b\u8c03\u5ea6O(1)\u7b97\u6cd5&#xff01;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>4. \u73af\u5883\u53d8\u91cf<\/h3>\n<h4>4.1 \u57fa\u672c\u6982\u5ff5<\/h4>\n<ul>\n<li>\u73af\u5883\u53d8\u91cf(environment variables)\u4e00\u822c\u662f\u6307\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u7528\u6765\u6307\u5b9a\u64cd\u4f5c\u7cfb\u7edf\u8fd0\u884c\u73af\u5883\u7684\u4e00\u4e9b\u53c2\u6570\u3002<\/li>\n<li>\u5982&#xff1a;\u6211\u4eec\u5728\u7f16\u5199C\/C&#043;&#043;\u4ee3\u7801\u7684\u65f6\u5019&#xff0c;\u5728\u94fe\u63a5\u7684\u65f6\u5019&#xff0c;\u4ece\u6765\u4e0d\u77e5\u9053\u6211\u4eec\u7684\u6240\u94fe\u63a5\u7684\u52a8\u6001\u9759\u6001\u5e93\u5728\u54ea\u91cc&#xff0c;\u4f46\u662f\u7167\u6837\u53ef\u4ee5\u94fe\u63a5\u6210\u529f&#xff0c;\u751f\u6210\u53ef\u6267\u884c\u7a0b\u5e8f&#xff0c;\u539f\u56e0\u5c31\u662f\u6709\u76f8\u5173\u73af\u5883\u53d8\u91cf\u5e2e\u52a9\u7f16\u8bd1\u5668\u8fdb\u884c\u67e5\u627e\u3002<\/li>\n<li>\u73af\u5883\u53d8\u91cf\u901a\u5e38\u5177\u6709\u67d0\u4e9b\u7279\u6b8a\u7528\u9014&#xff0c;\u8fd8\u6709\u5728\u7cfb\u7edf\u5f53\u4e2d\u901a\u5e38\u5177\u6709\u5168\u5c40\u7279\u6027&#xff0c;\u5176\u610f\u5473\u7740\u53ef\u4ee5\u88ab\u5b50\u8fdb\u7a0b\u7ee7\u627f\u3002\u800c\u672c\u5730\u53d8\u91cf\u4e0d\u4f1a\u88ab\u5b50\u8fdb\u7a0b\u7ee7\u627f&#xff0c;\u53ea\u5728bash\u5185\u90e8\u88ab\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>4.2 \u5e38\u89c1\u7684\u73af\u5883\u53d8\u91cf<\/h4>\n<ul>\n<li>PATH&#xff1a;\u6307\u5b9a\u547d\u4ee4\u7684\u641c\u7d22\u8def\u5f84<\/li>\n<li>HOME&#xff1a;\u6307\u5b9a\u7528\u6237\u7684\u4e3b\u5de5\u4f5c\u76ee\u5f55(\u5373\u7528\u6237\u767b\u9646\u5230Linux\u7cfb\u7edf\u4e2d\u65f6,\u9ed8\u8ba4\u7684\u76ee\u5f55)<\/li>\n<li>SHELL&#xff1a;\u5f53\u524dShell,\u5b83\u7684\u503c\u901a\u5e38\u662f\/bin\/bash\u3002<\/li>\n<li>USER&#xff1a;\u6307\u5b9a\u5f53\u524d\u767b\u5f55\u7684\u7528\u6237\u540d\u3002<\/li>\n<li>LOGNAME&#xff1a;\u6307\u5b9a\u5f53\u524d\u767b\u5f55\u7684\u7528\u6237\u540d&#xff0c;\u4f46\u66f4\u504f\u5411\u4e8e \u7cfb\u7edf\u767b\u5f55\u8bb0\u5f55 \u7684\u539f\u59cb\u7528\u6237\u540d\u3002\u56e0\u6b64\u5373\u4f7f\u7528\u6237\u901a\u8fc7 su \u6216 sudo \u5207\u6362\u8eab\u4efd&#xff0c;LOGNAME \u4ecd\u4fdd\u6301\u6700\u521d\u7684\u767b\u5f55\u7528\u6237\u540d\u3002<\/li>\n<li>PWD&#xff1a;\u6307\u5b9a\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\u7684\u8def\u5f84&#xff08;\u7531 Shell \u52a8\u6001\u66f4\u65b0&#xff09;\u3002<\/li>\n<li>OLDPWD&#xff1a;\u6307\u5b9a\u4e0a\u4e00\u6b21\u6240\u5728\u7684\u5de5\u4f5c\u76ee\u5f55\u8def\u5f84&#xff08;\u53ef\u901a\u8fc7 cd &#8211; \u5207\u6362\u56de\u53bb&#xff09;\u3002<\/li>\n<li>HOSTNAME&#xff1a;\u6307\u5b9a\u5f53\u524d\u7cfb\u7edf\u7684\u4e3b\u673a\u540d&#xff08;hostname&#xff09;&#xff0c;\u7528\u4e8e\u6807\u8bc6\u7f51\u7edc\u4e2d\u7684\u8ba1\u7b97\u673a\u3002\u5f71\u54cd\u7ec8\u7aef\u63d0\u793a\u7b26\u3001\u7f51\u7edc\u901a\u4fe1&#xff08;\u5982 SSH&#xff09;\u3001\u7cfb\u7edf\u65e5\u5fd7\u7b49\u573a\u666f\u3002<\/li>\n<li>HISTSIZE&#xff1a;\u6307\u5b9a Shell \u5386\u53f2\u8bb0\u5f55&#xff08;history \u547d\u4ee4&#xff09;\u5728 \u5185\u5b58\u4e2d \u4fdd\u5b58\u7684\u6700\u5927\u547d\u4ee4\u6761\u6570\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>4.3 \u5173\u4e8e\u73af\u5883\u53d8\u91cf\u7684\u547d\u4ee4<\/h4>\n<ul>\n<li>echo&#xff1a;\u663e\u793a\u67d0\u4e2a\u73af\u5883\u53d8\u91cf\u503c\u3002\u5982echo $VAR_NAME<\/li>\n<li>export&#xff1a;\u8bbe\u7f6e\u4e00\u4e2a\u65b0\u7684\u73af\u5883\u53d8\u91cf&#xff0c;\u4ec5\u5bf9\u5f53\u524d Shell \u53ca\u5176\u5b50\u8fdb\u7a0b\u6709\u6548&#xff0c;\u5173\u95ed\u7ec8\u7aef\u540e\u5931\u6548\u3002\u5982export VAR_NAME&#061;value<\/li>\n<li>env&#xff1a;\u663e\u793a\u6240\u6709\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<li>unset&#xff1a;\u5220\u9664\u73af\u5883\u53d8\u91cf\u3002\u5982unset VAR_NAME<\/li>\n<li>set&#xff1a;\u663e\u793a\u6240\u6709\u53d8\u91cf&#xff08;\u5305\u62ec\u73af\u5883\u53d8\u91cf\u548cShell\u672c\u5730\u53d8\u91cf&#xff09;\u3002<\/li>\n<li>\u5185\u5efa\u547d\u4ee4built-in command&#xff1a;\u4e0d\u9700\u8981\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff0c;\u800c\u662f\u8ba9bash\u81ea\u5df1\u8c03\u7528\u51fd\u6570\u6216\u662f\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\u6267\u884c\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>4.4 \u901a\u8fc7\u4ee3\u7801\u83b7\u53d6\u73af\u5883\u53d8\u91cf<\/h4>\n<ul>\n<li>\n<p>main\u51fd\u6570\u7684\u7b2c\u4e09\u4e2a\u53c2\u6570<\/p>\n<p>   <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>env<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">;<\/span> env<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> env<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u7b2c\u4e09\u65b9\u53d8\u91cfenviron\u83b7\u53d6<\/p>\n<p>   <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> argc<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span>argv<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">extern<\/span> <span class=\"token keyword\">char<\/span> <span class=\"token operator\">*<\/span><span class=\"token operator\">*<\/span>environ<span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/libc\u4e2d\u5b9a\u4e49\u7684\u5168\u5c40\u53d8\u91cfenviron\u6307\u5411\u73af\u5883\u53d8\u91cf\u8868,<\/span><br \/>\n    <span class=\"token comment\">\/\/environ\u6ca1\u6709\u5305\u542b\u5728\u4efb\u4f55\u5934\u2f42\u4ef6\u4e2d,\u6240\u4ee5\u5728\u4f7f\u2f64\u65f6 \u8981\u2f64extern\u58f0\u660e\u3002<\/span><br \/>\n<span class=\"token keyword\">int<\/span> i <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">for<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">;<\/span> environ<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> environ<span class=\"token punctuation\">[<\/span>i<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7\u7cfb\u7edf\u8c03\u7528\u83b7\u53d6<\/p>\n<p>   <span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;%s\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getenv<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;PATH&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u53ef\u4ee5\u7528\u6765\u5b9e\u73b0\u4e00\u4e2a\u52a0\u5bc6\u7684\u5c0f\u7a0b\u5e8f<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<\/li>\n<\/ul>\n<h4>4.5 bash\u7684\u4e24\u5f20\u8868<\/h4>\n<ul>\n<li>\n<p>\u6bcf\u6709\u4e00\u4e2a\u7528\u6237\u767b\u5f55\u5c31\u4f1a\u6709\u4e00\u4e2abash&#xff0c;\u800cbash\u5185\u90e8\u4f1a\u5b58\u5728\u4e24\u5f20\u8868\u3002\u7b2c\u4e00\u5f20\u8868\u662f\u547d\u4ee4\u884c\u53c2\u6570\u8868char *argv[]&#xff0c;\u7b2c\u4e8c\u5f20\u8868\u662f\u73af\u5883\u53d8\u91cf\u8868char *env[]\u3002<\/p>\n<\/li>\n<li>\n<p>\u547d\u4ee4\u884c\u53c2\u6570\u8868\u662fbash\u5bf9\u4e8e\u8f93\u5165\u7684\u547d\u4ee4\u8fdb\u884c\u7684\u5207\u5206&#xff0c;\u53ef\u4ee5\u7528\u6765\u5206\u6790\u548c\u5b9e\u73b0\u7a0b\u5e8f\u4e0d\u540c\u5b50\u529f\u80fd&#xff08;\u547d\u4ee4\u53c2\u6570\u9009\u9879&#xff09;\u7684\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<li>\n<p>\u73af\u5883\u53d8\u91cf\u8868\u662fbash\u6700\u5f00\u59cb\u4ece\u7cfb\u7edf\u7684\u76f8\u5173\u914d\u7f6e\u6587\u4ef6\u4e2d\u62f7\u8d1d\u8fc7\u6765\u7684&#xff0c;\u7528\u6765\u5e2e\u52a9\u7528\u6237\u548c\u64cd\u4f5c\u7cfb\u7edf\u7684\u8fd0\u884c\u3002\u5176\u662f\u2f00\u4e2a\u5b57\u7b26\u6307\u9488\u6570\u7ec4&#xff0c;\u6bcf\u4e2a\u6307\u9488\u6307\u5411\u2f00\u4e2a\u4ee5\u2019\\\\0\u2019\u7ed3\u5c3e\u7684\u73af\u5883\u5b57\u7b26\u4e32\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115624-68023de83b4b3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>5. \u7a0b\u5e8f\u5730\u5740\u7a7a\u95f4<\/h3>\n<p>\u7a0b\u5e8f\u5730\u5740\u7a7a\u95f4\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u5185\u5b58<\/p>\n<h4>5.1 \u865a\u62df\u5730\u5740<\/h4>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;unistd.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdlib.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> g_val <span class=\"token operator\">&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token class-name\">pid_t<\/span> id <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">fork<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">if<\/span><span class=\"token punctuation\">(<\/span>id <span class=\"token operator\">&lt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token function\">perror<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;fork&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">else<\/span> <span class=\"token keyword\">if<\/span><span class=\"token punctuation\">(<\/span>id <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span> <span class=\"token comment\">\/\/child,\u2f26\u8fdb\u7a0b\u80af\u5b9a\u5148\u8dd1\u5b8c&#xff0c;\u4e5f\u5c31\u662f\u2f26\u8fdb\u7a0b\u5148\u4fee\u6539&#xff0c;\u5b8c\u6210\u4e4b\u540e&#xff0c;\u2f57\u8fdb\u7a0b\u518d\u8bfb\u53d6<\/span><br \/>\ng_val<span class=\"token operator\">&#061;<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;child[%d]: %d : %p\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> g_val<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>g_val<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token keyword\">else<\/span><span class=\"token punctuation\">{<\/span> <span class=\"token comment\">\/\/parent<\/span><br \/>\n<span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;parent[%d]: %d : %p\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token function\">getpid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> g_val<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&amp;<\/span>g_val<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">sleep<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8f93\u51fa\u7ed3\u679c&#xff1a;<\/p>\n<p>child<span class=\"token punctuation\">[<\/span><span class=\"token number\">3046<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">100<\/span> <span class=\"token operator\">:<\/span> <span class=\"token number\">0x80497e8<\/span><br \/>\nparent<span class=\"token punctuation\">[<\/span><span class=\"token number\">3045<\/span><span class=\"token punctuation\">]<\/span><span class=\"token operator\">:<\/span> <span class=\"token number\">0<\/span> <span class=\"token operator\">:<\/span> <span class=\"token number\">0x80497e8<\/span><\/p>\n<p>\u6839\u636e\u4e0a\u8fb9\u7684\u4ee3\u7801\u6211\u4eec\u53ef\u4ee5\u770b\u51fa&#xff0c;\u7236\u5b50\u8fdb\u7a0b\u7684\u8f93\u51fa\u5730\u5740\u662f\u4e00\u81f4\u7684&#xff0c;\u4f46\u662f\u53d8\u91cf\u5185\u5bb9\u5374\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u7ed3\u8bba&#xff1a;<\/p>\n<ul>\n<li>\u53d8\u91cf\u5185\u5bb9\u4e0d\u4e00\u6837,\u6240\u4ee5\u7236\u5b50\u8fdb\u7a0b\u8f93\u51fa\u7684\u53d8\u91cf\u7edd\u5bf9\u4e0d\u662f\u540c\u4e00\u4e2a\u53d8\u91cf\u3002<\/li>\n<li>\u4f46\u5730\u5740\u503c\u662f\u4e00\u6837\u7684&#xff0c;\u8bf4\u660e&#xff0c;\u8be5\u5730\u5740\u7edd\u5bf9\u4e0d\u662f\u7269\u7406\u5730\u5740&#xff01;<\/li>\n<li>\u5728Linux\u5730\u5740\u4e0b&#xff0c;\u8fd9\u79cd\u5730\u5740\u53eb\u505a \u865a\u62df\u5730\u5740\u3002\u865a\u62df\u5730\u5740\u53ef\u4ee5\u76f8\u540c&#xff0c;\u4f46\u7269\u7406\u5730\u5740\u4e00\u5b9a\u4e0d\u540c\u3002<\/li>\n<li>\u6211\u4eec\u5728\u7528C\/C&#043;&#043;\u8bed\u8a00\u6240\u770b\u5230\u7684\u5730\u5740&#xff0c;\u5168\u90e8\u90fd\u662f\u865a\u62df\u5730\u5740&#xff01;\u7269\u7406\u5730\u5740&#xff0c;\u7528\u6237\u4e00\u6982\u770b\u4e0d\u5230&#xff0c;\u7531OS\u7edf\u4e00\u7ba1\u7406\u3002<\/li>\n<li>OS\u5fc5\u987b\u8d1f\u8d23\u5c06\u865a\u62df\u5730\u5740\u8f6c\u6362\u6210\u7269\u7406\u5730\u5740\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>5.2 \u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4&#xff08;\u91cd\u8981&#xff09;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115624-68023de854fa6.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u4e00\u4e2a\u8fdb\u7a0b\u5c31\u4f1a\u6709\u4e00\u4e2a\u865a\u62df\u5730\u5740\u7a7a\u95f4&#xff08;\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4&#xff09;&#xff1b;\u4e00\u4e2a\u8fdb\u7a0b\u5c31\u6709\u4e00\u5957\u9875\u8868&#xff0c;\u800c\u9875\u8868\u662f\u7528\u6765\u505a\u865a\u62df\u5730\u5740\u548c\u7269\u7406\u5730\u5740\u6620\u5c04\u7684\u3002\u9875\u8868\u4e2d\u5176\u5b9e\u8fd8\u6709\u4e00\u5217\u5b58\u50a8\u7684\u662f\u5185\u5bb9\u7684\u8bbf\u95ee\u6743\u9650\u2014\u2014\u5728\u5730\u5740\u8f6c\u6362\u8fc7\u7a0b\u4e2d&#xff0c;\u5bf9\u4f60\u7684\u5730\u5740\u548c\u64cd\u4f5c\u8fdb\u884c\u5408\u6cd5\u6027\u5224\u5b9a&#xff0c;\u8fdb\u800c\u4fdd\u62a4\u7269\u7406\u5185\u5b58\u3002<\/li>\n<li>\u865a\u62df\u5730\u5740\u7a7a\u95f4\u672c\u8d28\u5c31\u662f\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<li>\u5176\u521d\u7ea7\u4f5c\u7528\u662f\u4e3a\u4e86\u8ba9\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u8ba4\u4e3a\u81ea\u5df1\u67094GB\u7684\u7269\u7406\u5185\u5b58&#xff0c;\u6216\u662f\u8ba9\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u8ba4\u4e3a\u81ea\u5df1\u5728\u72ec\u5360\u7269\u7406\u5185\u5b58\u3002<\/li>\n<li>\u533a\u57df\u5212\u5206&#xff1a;\u5bf9\u6574\u4e2a\u865a\u62df\u5730\u5740\u7a7a\u95f4\u8fdb\u884c\u7f16\u5740&#xff0c;\u6b64\u65f6\u5730\u5740\u7a7a\u95f4\u4fbf\u6709\u4e86\u4e00\u4e2a\u4e2a\u5730\u5740\u3002\u7136\u540e\u53ea\u9700\u8981\u8bb0\u5f55\u6bcf\u5757\u533a\u57df\u7684\u5f00\u59cb\u5730\u5740\u548c\u7ed3\u675f\u5730\u5740\u5373\u53ef\u3002<\/li>\n<\/ul>\n<hr \/>\n<h4>5.3 \u865a\u62df\u5185\u5b58\u7ba1\u7406\u7b2c\u4e00\u8bb2<\/h4>\n<p>\u63cf\u8ff0Linux\u4e0b\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u7684\u6240\u6709\u7684\u4fe1\u606f\u7684\u7ed3\u6784\u4f53\u662f mm_struct&#xff08;\u5185\u5b58\u63cf\u8ff0\u7b26&#xff09;\u3002\u6bcf\u4e2a\u8fdb\u7a0b\u53ea\u6709\u2f00\u4e2amm_struct\u7ed3\u6784&#xff0c;\u5728\u6bcf\u4e2a\u8fdb\u7a0b\u7684task_struct\u7ed3\u6784\u4e2d&#xff0c;\u6709\u2f00\u4e2a\u6307\u5411\u8be5\u8fdb\u7a0b\u7684\u7ed3\u6784\u3002<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">task_struct<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token comment\">\/*&#8230;*\/<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">mm_struct<\/span> <span class=\"token operator\">*<\/span>mm<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u5bf9\u4e8e\u666e\u901a\u7684\u2f64\u2f3e\u8fdb\u7a0b\u6765\u8bf4\u8be5\u5b57\u6bb5\u6307\u5411\u4ed6\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u7684\u2f64\u2f3e\u7a7a\u95f4\u90e8\u5206&#xff0c;\u5bf9\u4e8e\u5185\u6838\u7ebf\u7a0b\u6765\u8bf4\u8fd9\u90e8\u5206\u4e3aNULL\u3002<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">mm_struct<\/span> <span class=\"token operator\">*<\/span>active_mm<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u8be5\u5b57\u6bb5\u662f\u5185\u6838\u7ebf\u7a0b\u4f7f\u2f64\u7684\u3002\u5f53\u8be5\u8fdb\u7a0b\u662f\u5185\u6838\u7ebf\u7a0b\u65f6&#xff0c;\u5b83\u7684mm\u5b57\u6bb5\u4e3aNULL&#xff0c;\u8868\u2f70\u6ca1\u6709\u5185\u5b58\u5730\u5740\u7a7a\u95f4&#xff0c;\u53ef\u4e5f\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u6ca1\u6709&#xff0c;\u8fd9\u662f\u56e0\u4e3a\u6240\u6709\u8fdb\u7a0b\u5173\u4e8e\u5185\u6838\u7684\u6620\u5c04\u90fd\u662f\u2f00\u6837\u7684&#xff0c;\u5185\u6838\u7ebf\u7a0b\u53ef\u4ee5\u4f7f\u2f64\u4efb\u610f\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u3002<\/span><br \/>\n<span class=\"token comment\">\/*&#8230;*\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u53ef\u4ee5\u8bf4&#xff0c;mm_struct\u7ed3\u6784\u662f\u5bf9\u6574\u4e2a\u7528\u6237\u7a7a\u95f4\u7684\u63cf\u8ff0\u3002\u6bcf\u2f00\u4e2a\u8fdb\u7a0b\u90fd\u4f1a\u6709\u81ea\u5df1\u72ec\u7acb\u7684mm_struct&#xff0c;\u8fd9\u6837\u6bcf\u2f00\u4e2a\u8fdb\u7a0b\u90fd\u4f1a\u6709\u2f83\u2f30\u72ec\u2f74\u7684\u5730\u5740\u7a7a\u95f4\u624d\u80fd\u4e92\u4e0d\u2f32\u6270\u3002\u5148\u6765\u770b\u770b\u7531task_struct\u5230mm_struct&#xff0c;\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u7684\u5206\u5e03\u60c5\u51b5&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115625-68023de9f400e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">mm_struct<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token comment\">\/*&#8230;*\/<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_area_struct<\/span> <span class=\"token operator\">*<\/span>mmap<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* \u6307\u5411\u865a\u62df\u533a\u95f4(VMA)\u94fe\u8868 *\/<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">rb_root<\/span> mm_rb<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* red_black\u6811 *\/<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> task_size<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/*\u5177\u6709\u8be5\u7ed3\u6784\u4f53\u7684\u8fdb\u7a0b\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u7684\u2f24\u2f29*\/<\/span><br \/>\n<span class=\"token comment\">\/*&#8230;*\/<\/span><br \/>\n<span class=\"token comment\">\/\/ \u4ee3\u7801\u6bb5\u3001\u6570\u636e\u6bb5\u3001\u5806\u6808\u6bb5\u3001\u53c2\u6570\u6bb5\u53ca\u73af\u5883\u6bb5\u7684\u8d77\u59cb\u548c\u7ed3\u675f\u5730\u5740\u3002<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> start_code<span class=\"token punctuation\">,<\/span> end_code<span class=\"token punctuation\">,<\/span> start_data<span class=\"token punctuation\">,<\/span> end_data<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> start_brk<span class=\"token punctuation\">,<\/span> brk<span class=\"token punctuation\">,<\/span> start_stack<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> arg_start<span class=\"token punctuation\">,<\/span> arg_end<span class=\"token punctuation\">,<\/span> env_start<span class=\"token punctuation\">,<\/span> env_end<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/*&#8230;*\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u90a3\u65e2\u7136\u6bcf\u2f00\u4e2a\u8fdb\u7a0b\u90fd\u4f1a\u6709\u2f83\u2f30\u72ec\u2f74\u7684mm_struct&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u80af\u5b9a\u662f\u8981\u5c06\u8fd9\u4e48\u591a\u8fdb\u7a0b\u7684mm_struct\u7ec4\u7ec7\u8d77\u6765\u7684&#xff01;\u865a\u62df\u7a7a\u95f4\u7684\u7ec4\u7ec7\u2f45\u5f0f\u6709\u4e24\u79cd&#xff1a;<\/p>\n<li>\u5f53\u865a\u62df\u533a\u8f83\u5c11\u65f6\u91c7\u53d6\u5355\u94fe\u8868&#xff0c;\u7531mmap\u6307\u9488\u6307\u5411\u8fd9\u4e2a\u94fe\u8868&#xff1b;<\/li>\n<li>\u5f53\u865a\u62df\u533a\u95f4\u591a\u65f6\u91c7\u53d6\u7ea2\u2fca\u6811\u8fdb\u2f8f\u7ba1\u7406&#xff0c;\u7531mm_rb\u6307\u5411\u8fd9\u68f5\u6811\u3002<\/li>\n<p>Linux\u5185\u6838\u4f7f\u7528 vm_area_struct \u7ed3\u6784\u6765\u8868\u793a\u4e00\u4e2a\u72ec\u2f74\u7684\u865a\u62df\u5185\u5b58\u533a\u57df(VMA)&#xff0c;\u7531\u4e8e\u6bcf\u4e2a\u4e0d\u540c\u8d28\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u529f\u80fd\u548c\u5185\u90e8\u673a\u5236\u90fd\u4e0d\u540c&#xff0c;\u56e0\u6b64\u2f00\u4e2a\u8fdb\u7a0b\u4f7f\u7528\u591a\u4e2avm_area_struct\u7ed3\u6784\u6765\u5206\u522b\u8868\u793a\u4e0d\u540c\u7c7b\u578b\u7684\u865a\u62df\u5185\u5b58\u533a\u57df\u3002\u4e0a\u9762\u63d0\u5230\u7684\u4e24\u79cd\u7ec4\u7ec7\u2f45\u5f0f\u4f7f\u2f64\u7684\u5c31\u662fvm_area_struct\u7ed3\u6784\u6765\u8fde\u63a5\u5404\u4e2aVMA&#xff0c;\u65b9\u4fbf\u8fdb\u7a0b\u5feb\u901f\u8bbf\u95ee\u3002<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_area_struct<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> vm_start<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u865a\u5b58\u533a\u8d77\u59cb<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> vm_end<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u865a\u5b58\u533a\u7ed3\u675f<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_area_struct<\/span> <span class=\"token operator\">*<\/span>vm_next<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span>vm_prev<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u524d\u540e\u6307\u9488<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">rb_node<\/span> vm_rb<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u7ea2\u2fca\u6811\u4e2d\u7684\u4f4d\u7f6e<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> rb_subtree_gap<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">mm_struct<\/span> <span class=\"token operator\">*<\/span>vm_mm<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u6240\u5c5e\u7684 mm_struct<\/span><br \/>\n<span class=\"token class-name\">pgprot_t<\/span> vm_page_prot<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> vm_flags<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u6807\u5fd7\u4f4d<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">rb_node<\/span> rb<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> rb_subtree_last<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> shared<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">list_head<\/span> anon_vma_chain<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">anon_vma<\/span> <span class=\"token operator\">*<\/span>anon_vma<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">const<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_operations_struct<\/span> <span class=\"token operator\">*<\/span>vm_ops<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/vma\u5bf9\u5e94\u7684\u5b9e\u9645\u64cd\u4f5c<\/span><br \/>\n<span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> vm_pgoff<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u2f42\u4ef6\u6620\u5c04\u504f\u79fb\u91cf<\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">file<\/span> <span class=\"token operator\">*<\/span> vm_file<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u6620\u5c04\u7684\u2f42\u4ef6<\/span><br \/>\n<span class=\"token keyword\">void<\/span> <span class=\"token operator\">*<\/span> vm_private_data<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/\u79c1\u6709\u6570\u636e<\/span><br \/>\n<span class=\"token class-name\">atomic_long_t<\/span> swap_readahead_info<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">ifndef<\/span> <span class=\"token expression\">CONFIG_MMU<\/span><\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_region<\/span> <span class=\"token operator\">*<\/span>vm_region<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* NOMMU mapping region *\/<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">endif<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">ifdef<\/span> <span class=\"token expression\">CONFIG_NUMA<\/span><\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">mempolicy<\/span> <span class=\"token operator\">*<\/span>vm_policy<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/* NUMA policy for the VMA *\/<\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">endif<\/span><\/span><br \/>\n<span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">vm_userfaultfd_ctx<\/span> vm_userfaultfd_ctx<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span> __randomize_layout<span class=\"token punctuation\">;<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115626-68023dea1e82b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115626-68023dea4ca82.png\" alt=\"\u5916\u94fe\u56fe\u7247\u8f6c\u5b58\u5931\u8d25,\u6e90\u7ad9\u53ef\u80fd\u6709\u9632\u76d7\u94fe\u673a\u5236,\u5efa\u8bae\u5c06\u56fe\u7247\u4fdd\u5b58\u4e0b\u6765\u76f4\u63a5\u4e0a\u4f20\" \/><\/p>\n<hr \/>\n<h4>5.4 \u4e3a\u4ec0\u4e48\u8981\u6709\u865a\u62df\u5185\u5b58\u7a7a\u95f4<\/h4>\n<p>\u4ea6\u6216\u662f\u5982\u679c\u7a0b\u5e8f\u76f4\u63a5\u53ef\u4ee5\u64cd\u4f5c\u7269\u7406\u5185\u5b58\u4f1a\u9020\u6210\u4ec0\u4e48\u95ee\u9898&#xff1f;<\/p>\n<p>\u5728\u65e9\u671f\u7684\u8ba1\u7b97\u673a\u4e2d&#xff0c;\u8981\u8fd0\u884c\u2f00\u4e2a\u7a0b\u5e8f&#xff0c;\u4f1a\u628a\u8fd9\u4e9b\u7a0b\u5e8f\u5168\u90fd\u88c5\u2f0a\u5185\u5b58&#xff0c;\u7a0b\u5e8f\u90fd\u662f\u76f4\u63a5\u8fd0\u2f8f\u5728\u5185\u5b58\u4e0a\u7684&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u7a0b\u5e8f\u4e2d\u8bbf\u95ee\u7684\u5185\u5b58\u5730\u5740\u90fd\u662f\u5b9e\u9645\u7684\u7269\u7406\u5185\u5b58\u5730\u5740\u3002\u5f53\u8ba1\u7b97\u673a\u540c\u65f6\u8fd0\u884c\u591a\u4e2a\u7a0b\u5e8f\u65f6&#xff0c;\u5fc5\u987b\u4fdd\u8bc1\u8fd9\u4e9b\u7a0b\u5e8f\u7528\u5230\u7684\u5185\u5b58\u603b\u91cf\u8981\u5c0f\u4e8e\u8ba1\u7b97\u673a\u5b9e\u9645\u7269\u7406\u5185\u5b58\u7684\u5927\u5c0f\u3002<\/p>\n<p>\u90a3\u5f53\u7a0b\u5e8f\u540c\u65f6\u8fd0\u884c\u591a\u4e2a\u7a0b\u5e8f\u65f6&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u662f\u5982\u4f55\u4e3a\u8fd9\u4e9b\u7a0b\u5e8f\u5206\u914d\u5185\u5b58\u7684\u5462&#xff1f;\u4f8b\u5982\u67d0\u53f0\u8ba1\u7b97\u673a\u603b\u7684\u5185\u5b58\u5927\u5c0f\u662f128M&#xff0c;\u73b0\u5728\u540c\u65f6\u8fd0\u2f8f\u4e24\u4e2a\u7a0b\u5e8fA\u548cB&#xff0c;A\u9700\u5360\u2f64\u5185\u5b5810M&#xff0c;B\u9700\u5360\u2f64\u5185\u5b58110\u3002\u8ba1\u7b97\u673a\u5728\u7ed9\u7a0b\u5e8f\u5206\u914d\u5185\u5b58\u65f6\u4f1a\u91c7\u53d6\u8fd9\u6837\u7684\u2f45\u6cd5&#xff1a;\u5148\u5c06\u5185\u5b58\u4e2d\u7684\u524d10M\u5206\u914d\u7ed9\u7a0b\u5e8fA&#xff0c;\u63a5\u7740\u518d\u4ece\u5185\u5b58\u4e2d\u5269\u4f59\u7684118M\u4e2d\u5212\u5206\u51fa110M\u5206\u914d\u7ed9\u7a0b\u5e8fB\u3002<\/p>\n<p>\u8fd9\u79cd\u5206\u914d\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u8bc1\u7a0b\u5e8fA\u548c\u7a0b\u5e8fB\u90fd\u80fd\u8fd0\u884c&#xff0c;\u4f46\u662f\u8fd9\u79cd\u7b80\u5355\u7684\u5185\u5b58\u5206\u914d\u7b56\u7565\u95ee\u9898\u5f88\u591a\u3002<\/p>\n<p>\u6bd4\u5982&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5b89\u5168\u2edb\u9669&#xff1a;<\/p>\n<p>\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u53ef\u4ee5\u8bbf\u95ee\u4efb\u610f\u7684\u5185\u5b58\u7a7a\u95f4&#xff0c;\u8fd9\u4e5f\u5c31\u610f\u5473\u7740\u4efb\u610f\u2f00\u4e2a\u8fdb\u7a0b\u90fd\u80fd\u591f\u53bb\u8bfb\u5199\u7cfb\u7edf\u76f8\u5173\u5185\u5b58\u533a\u57df&#xff0c;\u5982\u679c\u662f\u2f00\u4e2a\u6728\u9a6c\u75c5\u6bd2&#xff0c;\u90a3\u4e48\u4ed6\u5c31\u80fd\u968f\u610f\u7684\u4fee\u6539\u5185\u5b58\u7a7a\u95f4&#xff0c;\u8ba9\u8bbe\u5907\u76f4\u63a5\u762b\u75ea\u3002<\/p>\n<\/li>\n<li>\n<p>\u5730\u5740\u4e0d\u786e\u5b9a&#xff1a;<\/p>\n<p>\u4f17\u6240\u5468\u77e5&#xff0c;\u7f16\u8bd1\u5b8c\u6210\u540e\u7684\u7a0b\u5e8f\u662f\u5b58\u653e\u5728\u786c\u76d8\u4e0a\u7684&#xff0c;\u5f53\u8fd0\u884c\u7684\u65f6\u5019&#xff0c;\u9700\u8981\u5c06\u7a0b\u5e8f\u642c\u5230\u5185\u5b58\u5f53\u4e2d\u53bb\u8fd0\u884c&#xff0c;\u5982\u679c\u76f4\u63a5\u4f7f\u7528\u7269\u7406\u5730\u5740\u7684\u8bdd&#xff0c;\u6211\u4eec\u65e0\u6cd5\u786e\u5b9a\u5185\u5b58\u73b0\u5728\u4f7f\u7528\u5230\u54ea\u91cc\u4e86&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u62f7\u2ec9\u7684\u5b9e\u9645\u5185\u5b58\u5730\u5740\u6bcf\u2f00\u6b21\u8fd0\u2f8f\u90fd\u662f\u4e0d\u786e\u5b9a\u7684&#xff0c;\u2f50\u5982&#xff1a;\u7b2c\u4e00\u6b21\u6267\u2f8fa.out\u65f6\u5019&#xff0c;\u5185\u5b58\u5f53\u4e2d\u2f00\u4e2a\u8fdb\u7a0b\u90fd\u6ca1\u6709\u8fd0\u884c&#xff0c;\u6240\u4ee5\u642c\u79fb\u5230\u5185\u5b58\u5730\u5740\u662f0x00000000&#xff0c;\u4f46\u662f\u7b2c\u4e8c\u6b21\u7684\u65f6\u5019&#xff0c;\u5185\u5b58\u5df2\u7ecf\u670910\u4e2a\u8fdb\u7a0b\u5728\u8fd0\u884c\u4e86&#xff0c;\u90a3\u6267\u2f8fa.out\u7684\u65f6\u5019&#xff0c;\u5185\u5b58\u5730\u5740\u5c31\u4e0d\u2f00\u5b9a\u4e86\u3002<\/p>\n<\/li>\n<li>\n<p>\u6548\u7387\u4f4e\u4e0b&#xff1a;<\/p>\n<p>\u5982\u679c\u76f4\u63a5\u4f7f\u2f64\u7269\u7406\u5185\u5b58\u7684\u8bdd&#xff0c;\u2f00\u4e2a\u8fdb\u7a0b\u5c31\u662f\u4f5c\u4e3a\u2f00\u4e2a\u6574\u4f53&#xff08;\u5185\u5b58\u5757&#xff09;\u64cd\u4f5c\u7684&#xff0c;\u5982\u679c\u51fa\u73b0\u7269\u7406\u5185\u5b58\u4e0d\u591f\u2f64\u7684\u65f6\u5019&#xff0c;\u6211\u4eec\u2f00\u822c\u7684\u529e\u6cd5\u662f\u5c06\u4e0d\u5e38\u2f64\u7684\u8fdb\u7a0b\u62f7\u2ec9\u5230\u78c1\u76d8\u7684\u4ea4\u6362\u5206\u533a\u4e2d&#xff0c;\u597d\u817e\u51fa\u5185\u5b58&#xff0c;\u4f46\u662f\u5982\u679c\u662f\u7269\u7406\u5730\u5740\u7684\u8bdd&#xff0c;\u5c31\u9700\u8981\u5c06\u6574\u4e2a\u8fdb\u7a0b\u2f00\u8d77\u62f7\u2f9b&#xff0c;\u8fd9\u6837&#xff0c;\u5728\u5185\u5b58\u548c\u78c1\u76d8\u4e4b\u95f4\u62f7\u8d1d\u65f6\u95f4\u592a\u2ed3&#xff0c;\u6548\u7387\u4f4e\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u6709\u4e86\u865a\u62df\u5730\u5740\u7a7a\u95f4\u548c\u5206\u2eda\u673a\u5236\u5c31\u80fd\u89e3\u51b3\u4e86<\/p>\n<p>\u5730\u5740\u7a7a\u95f4\u548c\u2eda\u8868\u662fOS\u521b\u5efa\u5e76\u7ef4\u62a4\u7684&#xff01;\u4e5f\u5c31\u610f\u5473\u7740&#xff0c;\u51e1\u662f\u60f3\u4f7f\u7528\u5730\u5740\u7a7a\u95f4\u548c\u2eda\u8868\u8fdb\u2f8f\u6620\u5c04&#xff0c;\u4e5f\u2f00\u5b9a\u8981\u5728OS\u7684\u76d1\u7ba1\u4e4b\u4e0b\u6765\u8fdb\u2f8f\u8bbf\u95ee&#xff01;&#xff01;\u4e5f\u987a\u4fbf\u4fdd\u62a4\u4e86\u7269\u7406\u5185\u5b58\u4e2d\u7684\u6240\u6709\u7684\u5408\u6cd5\u6570\u636e &#xff0c;\u5305\u62ec\u5404\u4e2a\u8fdb\u7a0b\u4ee5\u53ca\u5185\u6838\u7684\u76f8\u5173\u6709\u6548\u6570\u636e\u3002<\/p>\n<p>\u56e0\u4e3a\u6709\u5730\u5740\u7a7a\u95f4\u7684\u5b58\u5728\u548c\u2eda\u8868\u7684\u6620\u5c04\u7684\u5b58\u5728&#xff0c;\u6211\u4eec\u7684\u7269\u7406\u5185\u5b58\u4e2d\u53ef\u4ee5\u5bf9\u672a\u6765\u7684\u6570\u636e\u8fdb\u2f8f\u4efb\u610f\u4f4d\u7f6e\u7684\u52a0\u8f7d&#xff01;\u7269\u7406\u5185\u5b58\u7684\u5206\u914d \u548c \u8fdb\u7a0b\u7684\u7ba1\u7406\u5c31\u53ef\u4ee5\u505a\u5230\u6ca1\u6709\u5173\u7cfb&#xff0c;\u8fdb\u7a0b\u7ba1\u7406\u6a21\u5757\u548c\u5185\u5b58\u7ba1\u7406\u6a21\u5757\u5c31\u5b8c\u6210\u4e86\u89e3\u8026\u5408\u3002<\/p>\n<p>\u56e0\u4e3a\u6709\u5730\u5740\u7a7a\u95f4\u7684\u5b58\u5728&#xff0c;\u6240\u4ee5\u6211\u4eec\u5728C\u3001C&#043;&#043;\u8bed\u2f94\u4e0anew, malloc\u7a7a\u95f4\u7684\u65f6\u5019&#xff0c;\u5176\u5b9e\u662f\u5728\u5730\u5740\u7a7a\u95f4\u4e0a\u7533\u8bf7\u7684&#xff0c;\u7269\u7406\u5185\u5b58\u751a\u2f84\u53ef\u4ee5\u2f00\u4e2a\u5b57\u8282\u90fd\u4e0d\u7ed9\u4f60\u3002\u800c\u5f53\u4f60\u771f\u6b63\u8fdb\u2f8f\u5bf9\u7269\u7406\u5730\u5740\u7a7a\u95f4\u8bbf\u95ee\u7684\u65f6\u5019&#xff0c;\u624d\u6267\u2f8f\u5185\u5b58\u7684\u76f8\u5173\u7ba1\u7406\u7b97\u6cd5&#xff0c;\u5e2e\u4f60\u7533\u8bf7\u5185\u5b58&#xff0c;\u6784\u5efa\u2eda\u8868\u6620\u5c04\u5173\u7cfb&#xff08;\u5ef6\u8fdf\u5206\u914d&#xff09;&#xff0c;\u8fd9\u662f\u7531\u64cd\u4f5c\u7cfb\u7edf\u2f83\u52a8\u5b8c\u6210&#xff0c;\u7528\u6237\u5305\u62ec\u8fdb\u7a0b\u5b8c\u5168\u96f6\u611f\u77e5&#xff01;&#xff01;<\/p>\n<p>\u56e0\u4e3a\u9875\u8868\u7684\u6620\u5c04\u7684\u5b58\u5728&#xff0c;\u7a0b\u5e8f\u5728\u7269\u7406\u5185\u5b58\u4e2d\u7406\u8bba\u4e0a\u5c31\u53ef\u4ee5\u4efb\u610f\u4f4d\u7f6e\u52a0\u8f7d\u3002\u5b83\u53ef\u4ee5\u5c06\u5730\u5740\u7a7a\u95f4\u4e0a\u7684\u865a\u62df\u5730\u5740\u548c\u7269\u7406\u5730\u5740\u8fdb\u2f8f\u6620\u5c04&#xff0c;\u5728 \u8fdb\u7a0b\u89c6\u2ec6\u6240\u6709\u7684\u5185\u5b58\u5206\u5e03\u90fd\u53ef\u4ee5\u662f\u6709\u5e8f \u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e33\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u7406\u89e3\u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0d\u4ec5\u6709\u52a9\u4e8e\u6211\u4eec\u638c\u63e1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u8fd8\u80fd\u4e3a\u540e\u7eed\u5b66\u4e60\u591a\u4efb\u52a1\u5904\u7406\u3001\u5e76\u53d1\u7f16\u7a0b\u3001\u5185\u5b58\u7ba1\u7406\u7b49\u9ad8\u7ea7\u4e3b\u9898\u5960\u5b9a\u575a\u5b9e\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u7684\u65b9\u65b9\u9762\u9762\uff0c\u5305\u62ec\u5176\u57fa\u672c\u6982\u5ff5\u3001\u72b6\u6001\u7ba1\u7406\u3001\u4f18\u5148\u7ea7\u8c03\u5ea6\u3001\u5730\u5740\u7a7a\u95f4\u7b49\u6838\u5fc3\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u793a\u4f8b\u548c\u4ee3\u7801\u5206\u6790\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u5b8c\u6574\u7684\u77e5\u8bc6\u4f53\u7cfb\u3002<\/p>\n","protected":false},"author":2,"featured_media":12845,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,103,305],"topic":[],"class_list":["post-12865","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-ubuntu","tag-305"],"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 \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \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\/12865.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 \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e33\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u7406\u89e3\u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0d\u4ec5\u6709\u52a9\u4e8e\u6211\u4eec\u638c\u63e1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u8fd8\u80fd\u4e3a\u540e\u7eed\u5b66\u4e60\u591a\u4efb\u52a1\u5904\u7406\u3001\u5e76\u53d1\u7f16\u7a0b\u3001\u5185\u5b58\u7ba1\u7406\u7b49\u9ad8\u7ea7\u4e3b\u9898\u5960\u5b9a\u575a\u5b9e\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u7684\u65b9\u65b9\u9762\u9762\uff0c\u5305\u62ec\u5176\u57fa\u672c\u6982\u5ff5\u3001\u72b6\u6001\u7ba1\u7406\u3001\u4f18\u5148\u7ea7\u8c03\u5ea6\u3001\u5730\u5740\u7a7a\u95f4\u7b49\u6838\u5fc3\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u793a\u4f8b\u548c\u4ee3\u7801\u5206\u6790\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u5b8c\u6574\u7684\u77e5\u8bc6\u4f53\u7cfb\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12865.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-18T11:56:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115622-68023de65c66e.png\" \/>\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=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12865.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12865.html\",\"name\":\"\u64cd\u4f5c\u7cfb\u7edf \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T11:56:27+00:00\",\"dateModified\":\"2025-04-18T11:56:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12865.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12865.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12865.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 \uff1a\u8fdb\u7a0b\u6982\u5ff5\"}]},{\"@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 \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \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\/12865.html","og_locale":"zh_CN","og_type":"article","og_title":"\u64cd\u4f5c\u7cfb\u7edf \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e33\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u7406\u89e3\u8fdb\u7a0b\u7684\u6982\u5ff5\u4e0d\u4ec5\u6709\u52a9\u4e8e\u6211\u4eec\u638c\u63e1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5de5\u4f5c\u539f\u7406\uff0c\u8fd8\u80fd\u4e3a\u540e\u7eed\u5b66\u4e60\u591a\u4efb\u52a1\u5904\u7406\u3001\u5e76\u53d1\u7f16\u7a0b\u3001\u5185\u5b58\u7ba1\u7406\u7b49\u9ad8\u7ea7\u4e3b\u9898\u5960\u5b9a\u575a\u5b9e\u7684\u57fa\u7840\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fdb\u7a0b\u7684\u65b9\u65b9\u9762\u9762\uff0c\u5305\u62ec\u5176\u57fa\u672c\u6982\u5ff5\u3001\u72b6\u6001\u7ba1\u7406\u3001\u4f18\u5148\u7ea7\u8c03\u5ea6\u3001\u5730\u5740\u7a7a\u95f4\u7b49\u6838\u5fc3\u5185\u5bb9\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u793a\u4f8b\u548c\u4ee3\u7801\u5206\u6790\uff0c\u5e2e\u52a9\u8bfb\u8005\u6784\u5efa\u5b8c\u6574\u7684\u77e5\u8bc6\u4f53\u7cfb\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/12865.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T11:56:27+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115622-68023de65c66e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12865.html","url":"https:\/\/www.wsisp.com\/helps\/12865.html","name":"\u64cd\u4f5c\u7cfb\u7edf \uff1a\u8fdb\u7a0b\u6982\u5ff5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T11:56:27+00:00","dateModified":"2025-04-18T11:56:27+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12865.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12865.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12865.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 \uff1a\u8fdb\u7a0b\u6982\u5ff5"}]},{"@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\/12865","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=12865"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12865\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/12845"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12865"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}