{"id":3348,"date":"2011-09-29T12:18:20","date_gmt":"2011-09-29T04:18:20","guid":{"rendered":"http:\/\/edsionte.com\/techblog\/?p=3348"},"modified":"2011-10-04T22:51:49","modified_gmt":"2011-10-04T14:51:49","slug":"%e5%8a%a8%e6%80%81%e7%9a%84%e8%bf%9b%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/edsionte.com\/techblog\/archives\/3348","title":{"rendered":"\u52a8\u6001\u7684\u8fdb\u7a0b"},"content":{"rendered":"<p>\u8fdb\u7a0b\u662f\u4e00\u4e2a\u52a8\u6001\u7684\u5b9e\u4f53\uff0c\u5b83\u662f\u7a0b\u5e8f\u7684\u4e00\u6b21\u6267\u884c\u8fc7\u7a0b\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8d44\u6e90\u5206\u914d\u7684\u57fa\u672c\u5355\u4f4d\u3002\u7a0b\u5e8f\u548c\u8fdb\u7a0b\u7684\u6700\u5927\u533a\u522b\u5728\u4e8e\u8fdb\u7a0b\u662f\u52a8\u6001\u8fd0\u884c\u7740\u7684\uff0c\u5b83\u5b58\u5728\u4e8e\u5185\u5b58\u4e2d\uff1b\u7a0b\u5e8f\u662f\u9759\u6001\u7684\uff0c\u5b83\u5b58\u5728\u4e8e\u78c1\u76d8\u4e0a\u3002<\/p>\n<p>\u8fd9\u91cc\u7684\u7a0b\u5e8f\u6307\u7684\u662f\u53ef\u6267\u884c\u6587\u4ef6\uff08\u5e76\u4e0d\u5305\u542b\u811a\u672c\u6587\u4ef6\uff09\uff0c\u901a\u5e38\u6211\u4eec\u6240\u8bf4\u7684\u6e90\u7a0b\u5e8f\u8981\u901a\u8fc7\u9884\u7f16\u8bd1\u3001\u7f16\u8bd1\u3001\u6c47\u7f16\u548c\u94fe\u63a5\u56db\u4e2a\u6b65\u9aa4\u8f6c\u5316\u4e3a\u53ef\u6267\u884c\u7a0b\u5e8f\u3002\u5f53\u6211\u4eec\u8fd0\u884c\u53ef\u6267\u884c\u7a0b\u5e8f\u65f6\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5c06\u53ef\u6267\u884c\u7a0b\u5e8f\u8bfb\u5165\u5185\u5b58\uff0c\u7a0b\u5e8f\u6447\u8eab\u4e00\u53d8\u8f6c\u5316\u4e3a\u4e00\u4e2a\u8fdb\u7a0b\u3002<\/p>\n<h4>1.\u8fdb\u7a0b\u7684\u72b6\u6001<\/h4>\n<p>\u8fdb\u7a0b\u662f\u4e00\u4e2a\u6d3b\u4f53\uff0c\u56e0\u6b64\u4e5f\u5c31\u968f\u4e4b\u8bde\u751f\u4e86\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u5728Linux\u5185\u6838\u4e2d\uff0c\u51e0\u79cd\u7ecf\u5178\u7684\u8fdb\u7a0b\u72b6\u6001\u5982\u4e0b\uff1a<\/p>\n<p><strong>\u53ef\u8fd0\u884c\u72b6\u6001<\/strong>\uff1a\u8868\u793a\u8fdb\u7a0b\u6b63\u5728\u8fd0\u884c\u6216\u8005\u6b63\u5728\u7b49\u5f85\u88ab\u8fd0\u884c\uff0c\u4e5f\u5c31\u662f\u64cd\u4f5c\u7cfb\u7edf\u539f\u7406\u4e2d\u7684\u8fd0\u884c\u6001\u548c\u5c31\u7eea\u6001\u3002Linux\u4f7f\u7528TASK_RUNNING\u5b8f\u8868\u793a\u6b64\u72b6\u6001\u3002<\/p>\n<p><strong>\u53ef\u4e2d\u65ad\u7684\u7b49\u5f85\u72b6\u6001<\/strong>\uff1a\u8fdb\u7a0b\u6b63\u5728\u7b49\u5f85\u67d0\u4e2a\u4e8b\u4ef6\u5b8c\u6210\uff0c\u5373\u64cd\u4f5c\u7cfb\u7edf\u539f\u7406\u4e2d\u7b49\u5f85\u6001\uff08\u6216\u963b\u585e\u6001\u3001\u7761\u7720\u6001\uff09\u3002\u5904\u4e8e\u8be5\u72b6\u6001\u7684\u8fdb\u7a0b\u5c5e\u4e8e\u201c\u8f7b\u5ea6\u7761\u7720\u201d\uff0c\u5b83\u53ef\u4ee5\u88ab\u4fe1\u53f7\u6216\u8005\u5b9a\u65f6\u5668\u5524\u9192\u3002Linux\u4e2d\u4f7f\u7528TASK_INTERRUPTIBLE\u6765\u8868\u793a\u6b64\u72b6\u6001\u3002<\/p>\n<p><strong>\u4e0d\u53ef\u4e2d\u65ad\u7684\u7b49\u5f85\u72b6\u6001<\/strong>\uff1a\u4e5f\u662f\u4e00\u79cd\u7b49\u5f85\u72b6\u6001\uff0c\u53ea\u4e0d\u8fc7\u5904\u4e8e\u8be5\u72b6\u6001\u7684\u8fdb\u7a0b\u5904\u4e8e\u201c\u6df1\u5ea6\u7761\u7720\u201d\uff0c\u5b83\u4e0d\u80fd\u88ab\u4fe1\u53f7\u6216\u8005\u5b9a\u65f6\u5668\u5524\u9192\uff0c\u53ea\u6709\u5f53\u5176\u7b49\u5f85\u7684\u4e8b\u4ef6\u53d1\u751f\u65f6\u624d\u53ef\u4ee5\u88ab\u5524\u9192\u3002Linux\u4e2d\u4f7f\u7528TASK_UNINTERRUPTIBLE\u6765\u8868\u793a\u8be5\u72b6\u6001\u3002<\/p>\n<p><strong>\u50f5\u6b7b\u72b6\u6001<\/strong>\uff1a\u8fdb\u7a0b\u5df2\u7ecf\u7ec8\u6b62\uff0c\u4f46\u662f\u5b83\u7684\u8fdb\u7a0b\u63cf\u8ff0\u7b26\u4ecd\u7136\u6ca1\u6709\u88ab\u64cd\u4f5c\u7cfb\u7edf\u6536\u56de\uff0c\u6b64\u65f6\u7684\u8fdb\u7a0b\u53ea\u6709\u8eab\u8eaf\u5e76\u65e0\u7075\u9b42\uff0c\u9700\u8981\u7236\u8fdb\u7a0b\u901a\u8fc7wait\u65cf\u51fd\u6570\u4e3a\u5176\u6536\u5c38\u3002Linux\u4e2d\u4f7f\u7528EXIT_ZOMBIE\u8868\u793a\u8be5\u72b6\u6001\u3002<\/p>\n<p><strong>\u505c\u6b62\u72b6\u6001<\/strong>\uff1a\u8fdb\u7a0b\u56e0\u4e3a\u6536\u5230SIGSTOP\u7b49\u4fe1\u53f7\u505c\u6b62\u8fd0\u884c\u3002Linux\u4e2d\u4f7f\u7528__TASK_TRACED\u8868\u793a\u8be5\u72b6\u6001\u3002<\/p>\n<p>\u9664\u4e86\u4e0a\u8ff0\u51e0\u79cd\u7ecf\u5178\u72b6\u6001\u5916\uff0c\u53ef\u4ee5\u5728sched.h\u4e2d\u67e5\u770b\u5176\u4ed6\u51e0\u79cd\u8fdb\u7a0b\u7684\u72b6\u6001\u3002\u6211\u4eec\u901a\u8fc7ps\u547d\u4ee4\u5728shell\u4e2d\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u6240\u6709\u8fdb\u7a0b\u7684\u72b6\u6001\u4fe1\u606f\u3002\u6bd4\u5982\uff1a<\/p>\n<pre class=\"brush:c\">edsionte@edsionte-desktop:~\/linux-3.0.4$ ps -eo pid,stat,command\r\n  PID STAT COMMAND\r\n    1 Ss   \/sbin\/init\r\n    2 S    [kthreadd]\r\n    3 S    [migration\/0]\r\n    4 S    [ksoftirqd\/0]\r\n    5 S    [watchdog\/0]\r\n    6 S    [migration\/1]\r\n    7 S    [ksoftirqd\/1]\r\n    8 S    [watchdog\/1]<\/pre>\n<p>\u6bcf\u884c\u4f9d\u6b21\u663e\u793a\u7684\u662f\u8fdb\u7a0b\u7684pid\u3001\u8fdb\u7a0b\u5f53\u524d\u7684\u72b6\u6001\u548c\u8fdb\u7a0b\u540d\u3002ps\u547d\u4ee4\u6240\u663e\u793a\u7684\u8fdb\u7a0b\u72b6\u6001\u901a\u8fc7\u4e00\u7ec4\u5b57\u6bcd\u7b26\u53f7\u6765\u8868\u793a\uff0c\u5404\u79cd\u7b26\u53f7\u7684\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush:c\">       D    Uninterruptible sleep (usually IO)\r\n       R    Running or runnable (on run queue)\r\n       S    Interruptible sleep (waiting for an event to complete)\r\n       T    Stopped, either by a job control signal or because it is being traced.\r\n       W    paging (not valid since the 2.6.xx kernel)\r\n       X    dead (should never be seen)\r\n       Z    Defunct (\"zombie\") process, terminated but not reaped by its parent.<\/pre>\n<h4>2.\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf<\/h4>\n<p>\u5728Linux\u4e2d\u53ef\u6267\u884c\u6587\u4ef6\uff08\u6b64\u5904\u5148\u5ffd\u7565\u811a\u672c\u6587\u4ef6\uff09\u7684\u683c\u5f0f\u4e3aELF\uff0c\u5373Executable and Linking Format\u3002\u867d\u7136\u53ef\u6267\u884c\u6587\u4ef6\u662f\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u4f46\u662f\u5b83\u7684\u5185\u90e8\u8fd8\u662f\u5212\u5206\u7740\u4e00\u4e9b\u533a\u57df\uff0c\u8fd9\u4e9b\u533a\u57df\u79f0\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6bb5\u3002\u8fd9\u91cc\u7684\u6bb5\u548cX86\u4f53\u7cfb\u67b6\u6784\u4e2d\u7684\u6bb5\u662f\u4e24\u4e2a\u5b8c\u5168\u4e0d\u540c\u7684\u6982\u5ff5\u3002<\/p>\n<p>\u901a\u5e38\u53ef\u6267\u884c\u6587\u4ef6\u5305\u542b\u4e00\u4e2a\u6587\u672c\u6bb5\uff08\u4ee3\u7801\u6bb5\uff09\uff0c\u6570\u636e\u6bb5\u3002\u6709\u65f6\u5019\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u8fd8\u989d\u5916\u5305\u542b\u4e00\u4e2aBSS\u6bb5\uff0c\u8fd9\u4e2a\u6bb5\u4e2d\u5b58\u653e\u7740\u90a3\u4e9b\u5728\u6e90\u7a0b\u5e8f\u4e2d\u6ca1\u6709\u88ab\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\u3002<\/p>\n<p>\u5f53\u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6\u65f6\uff0c\u5185\u6838\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u8bfb\u5165\u5185\u5b58\uff0c\u6211\u4eec\u5c06\u8bfb\u5165\u5185\u5b58\u4e2d\u7684\u53ef\u6267\u884c\u6587\u4ef6\u79f0\u4e4b\u4e3a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u3002\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u867d\u7136\u4e5f\u6839\u636e\u5b58\u653e\u5185\u5bb9\u7684\u4e0d\u540c\u5c06\u8fdb\u7a0b\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\u5212\u5206\u4e3a\u4e00\u5757\u4e00\u5757\u7684\uff0c\u4f46\u662f\u8fd9\u4e9b\u533a\u57df\u5728\u5185\u5b58\u4e2d\u5e76\u4e0d\u79f0\u4e4b\u4e3a\u6bb5\uff0c\u800c\u662f\u865a\u62df\u5185\u5b58\u533a\u57df\uff0c\u5185\u6838\u4f7f\u7528vm_area_struct\u7ed3\u6784\u6765\u8868\u793a\u8fd9\u7247\u5185\u5b58\u533a\u57df\u3002<\/p>\n<p>\u53ef\u6267\u884c\u6587\u4ef6\u548c\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u867d\u7136\u90fd\u6709\u4ee3\u7801\u6bb5\u548c\u6570\u636e\u6bb5\uff0c\u4f46\u4e24\u8005\u5176\u5b9e\u662f\u4e0d\u540c\u7684\u3002\u9996\u5148\u53ef\u6267\u884c\u6587\u4ef6\uff08\u4e5f\u5c31\u662f\u7a0b\u5e8f\uff09\u662f\u9759\u6001\u7684\uff0c\u5b58\u653e\u5728\u78c1\u76d8\u4e0a\uff0c\u800c\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u53ea\u6709\u5728\u7a0b\u5e8f\u8fd0\u884c\u65f6\u624d\u4ea7\u751f\uff1b\u5176\u6b21\uff0c\u53ef\u6267\u884c\u6587\u4ef6\u6ca1\u6709\u5806\u6808\u6bb5\uff0c\u800c\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u662f\u5305\u542b\u5806\u6808\u6bb5\u7684\uff0c\u56e0\u4e3a\u5806\uff08heap\uff09\u7528\u4e8e\u52a8\u6001\u5206\u914d\u5185\u5b58\uff0c\u800c\u6808\uff08stack\uff09\u9700\u8981\u4fdd\u5b58\u5c40\u90e8\u53d8\u91cf\u3001\u4e34\u65f6\u6570\u636e\u548c\u4f20\u9012\u5230\u51fd\u6570\u7684\u53c2\u6570\u7b49\u3002\u4ece\u8fd9\u4e9b\u4e0d\u540c\u70b9\u4e5f\u53ef\u4ee5\u8bf4\u660e\u7a0b\u5e8f\u662f\u52a8\u6001\u7684\u3002<\/p>\n<p>\u53ef\u6267\u884c\u6587\u4ef6\u7684\u6bb5\u5728\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u4e2d\u7684\u5206\u5e03\u56fe\u53ef\u4ee5\u53c2\u8003\u5982\u4e0b\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3348\/elf\" rel=\"attachment wp-att-3357\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3357\" title=\"elf\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/elf.jpeg\" alt=\"\" width=\"509\" height=\"424\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/elf.jpeg 636w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/elf-300x250.jpg 300w\" sizes=\"auto, (max-width: 509px) 100vw, 509px\" \/><\/a><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u5e76\u4e0d\u53ea\u5305\u542b\u4e00\u4e2a\u6587\u672c\u6bb5\u6216\u6570\u636e\u6bb5\uff0c\u7531\u4e8e\u5927\u591a\u6570\u6e90\u7a0b\u5e8f\u7684\u76ee\u6807\u6587\u4ef6\u5728\u94fe\u63a5\u65f6\u90fd\u9700\u8981\u94fe\u63a5\u4e00\u4e9b\u52a8\u6001\u5e93\uff0c\u6700\u7ec8\u5f62\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u56e0\u6b64\u8fdb\u7a0b\u7684\u5730\u5740\u7a7a\u95f4\u4e2d\u4f1a\u6709\u597d\u51e0\u4e2a\u6587\u672c\u6bb5\u548c\u6570\u636e\u6bb5\u533a\u57df\u3002\u800c\u4e14\u5728\u94fe\u63a5\u8fc7\u7a0b\u4e2d\uff0c\u8fd8\u9700\u8981\u52a0\u5165\u94fe\u63a5\u5668\uff08ld\uff09\uff0c\u56e0\u6b64\u8fdb\u7a0b\u5730\u7a7a\u95f4\u7cbe\u786e\u7684\u793a\u610f\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"http:\/\/edsionte.com\/techblog\/archives\/3348\/process_addr\" rel=\"attachment wp-att-3358\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3358\" title=\"process_addr\" src=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/process_addr.jpeg\" alt=\"\" width=\"377\" height=\"482\" srcset=\"http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/process_addr.jpeg 471w, http:\/\/edsionte.com\/techblog\/wordpress\/wp-content\/uploads\/2011\/09\/process_addr-234x300.jpg 234w\" sizes=\"auto, (max-width: 377px) 100vw, 377px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u5728\u4e00\u4e2a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u50cf\u4e2d\uff0c\u6587\u672c\u6bb5\u7528\u6765\u5b58\u653e\u4e8c\u8fdb\u5236\u7684\u53ef\u6267\u884c\u4ee3\u7801\uff0c\u800c\u6570\u636e\u6bb5\u7528\u6765\u5b58\u653e\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\uff0cBSS\u6bb5\u7528\u6765\u5b58\u653e\u672a\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u5806\u6bb5\u7528\u4e8e\u4e3amalloc\u51fd\u6570\u5206\u914d\u7a7a\u95f4\uff0c\u6808\u6bb5\u7528\u6765\u5b58\u653e\u5c40\u90e8\u53d8\u91cf\u548c\u5f62\u53c2\u7b49\u4e34\u65f6\u6570\u636e\u3002<\/p>\n<p><strong>\u53c2\u8003\uff1a<\/strong><\/p>\n<p><strong> 1. Linux C\u7f16\u7a0b\u5b9e\u6218<\/strong><br \/>\n<strong> 2. C\u4e13\u5bb6\u7f16\u7a0b<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fdb\u7a0b\u662f\u4e00\u4e2a\u52a8\u6001\u7684\u5b9e\u4f53\uff0c\u5b83\u662f\u7a0b\u5e8f\u7684\u4e00\u6b21\u6267\u884c\u8fc7\u7a0b\uff0c\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8d44\u6e90\u5206\u914d\u7684\u57fa\u672c\u5355\u4f4d\u3002\u7a0b\u5e8f\u548c\u8fdb\u7a0b\u7684\u6700\u5927\u533a\u522b\u5728\u4e8e\u8fdb\u7a0b\u662f\u52a8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[253],"tags":[254,183],"class_list":["post-3348","post","type-post","status-publish","format-standard","hentry","category-253","tag-254","tag-183"],"views":8397,"_links":{"self":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/comments?post=3348"}],"version-history":[{"count":0,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/posts\/3348\/revisions"}],"wp:attachment":[{"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/media?parent=3348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/categories?post=3348"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edsionte.com\/techblog\/wp-json\/wp\/v2\/tags?post=3348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}