{"id":122336,"date":"2026-11-04T18:49:09","date_gmt":"2026-11-04T10:49:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/122336.html"},"modified":"2026-11-04T18:49:09","modified_gmt":"2026-11-04T10:49:09","slug":"linux-%e8%bf%9b%e7%a8%8b%e4%bc%98%e5%85%88%e7%ba%a7%e3%80%81%e5%88%87%e6%8d%a2%e4%b8%8e%e8%b0%83%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/122336.html","title":{"rendered":"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p>\u4e00\u53f0\u673a\u5668\u4e0a\u540c\u65f6\u6709\u51e0\u767e\u4e2a\u8fdb\u7a0b&#xff0c;\u4f46 CPU \u6838\u5fc3\u6570\u8fdc\u5c11\u4e8e\u8fdb\u7a0b\u6570\u3002\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u8ba4\u4e3a\u81ea\u5df1\u5e94\u8be5\u7ee7\u7eed\u6267\u884c&#xff0c;\u800c\u64cd\u4f5c\u7cfb\u7edf\u5fc5\u987b\u5728\u6beb\u79d2\u7ea7\u505a\u51fa\u9009\u62e9&#xff1a;\u73b0\u5728\u628a CPU \u7ed9\u8c01&#xff1f;\u8fd9\u4e2a\u9009\u62e9\u7531\u4f18\u5148\u7ea7\u3001\u8c03\u5ea6\u5668\u548c\u4e0a\u4e0b\u6587\u5207\u6362\u5171\u540c\u5b8c\u6210\u3002<\/p>\n<h2>\u4e00\u3001\u4f18\u5148\u7ea7\u89e3\u51b3\u7684\u662f\u201c\u8c01\u5148\u8fd0\u884c\u201d<\/h2>\n<h3>1. \u7ade\u4e89\u3001\u5e76\u53d1\u4e0e\u5e76\u884c<\/h3>\n<p>\u8fdb\u7a0b\u4e4b\u95f4\u6700\u76f4\u63a5\u7684\u5173\u7cfb\u662f\u7ade\u4e89&#xff1a;CPU \u8d44\u6e90\u6709\u9650&#xff0c;\u800c\u53ef\u8fd0\u884c\u7684\u8fdb\u7a0b\u5f88\u591a\u3002\u4e3a\u4e86\u8ba9\u7ade\u4e89\u6709\u79e9\u5e8f&#xff0c;\u5185\u6838\u7ed9\u6bcf\u4e2a\u8fdb\u7a0b\u4e00\u4e2a\u53ef\u6bd4\u8f83\u7684\u4f18\u5148\u7ea7&#xff0c;\u8c03\u5ea6\u65f6\u4f18\u5148\u7167\u987e\u66f4\u91cd\u8981\u7684\u4efb\u52a1\u3002<\/p>\n<p>\u4e0b\u9762\u51e0\u4e2a\u6982\u5ff5\u7ecf\u5e38\u51fa\u73b0&#xff0c;\u5148\u505a\u4e2a\u8fa8\u6790&#xff1a;<\/p>\n<table>\n<tr>\u6982\u5ff5\u5173\u6ce8\u70b9\u5178\u578b\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>\u7ade\u4e89\u6027<\/td>\n<td>\u591a\u4e2a\u8fdb\u7a0b\u4e89\u62a2\u6709\u9650\u7684 CPU<\/td>\n<td>\u4e00\u8fb9\u7f16\u8bd1\u4ee3\u7801&#xff0c;\u4e00\u8fb9\u5f00\u89c6\u9891\u4f1a\u8bae<\/td>\n<\/tr>\n<tr>\n<td>\u72ec\u7acb\u6027<\/td>\n<td>\u6bcf\u4e2a\u8fdb\u7a0b\u6709\u81ea\u5df1\u7684\u5730\u5740\u7a7a\u95f4\u548c\u8fd0\u884c\u4e0a\u4e0b\u6587<\/td>\n<td>\u4e00\u4e2a\u8fdb\u7a0b\u5d29\u6e83&#xff0c;\u4e0d\u5f71\u54cd\u53e6\u4e00\u4e2a\u8fdb\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u53d1<\/td>\n<td>\u4e00\u4e2a CPU \u5728\u591a\u4e2a\u8fdb\u7a0b\u4e4b\u95f4\u5feb\u901f\u5207\u6362<\/td>\n<td>\u5355\u6838\u673a\u5668\u4e0a\u540c\u65f6\u4e0b\u8f7d\u3001\u64ad\u653e\u97f3\u4e50\u3001\u7f16\u8f91\u6587\u6863<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u884c<\/td>\n<td>\u591a\u4e2a CPU \u771f\u6b63\u540c\u65f6\u6267\u884c\u591a\u4e2a\u4efb\u52a1<\/td>\n<td>\u56db\u6838\u673a\u5668\u4e0a\u56db\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8ba1\u7b97<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5e76\u53d1\u662f\u201c\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u90fd\u5411\u524d\u8d70\u201d&#xff0c;\u5e76\u884c\u662f\u201c\u5728\u540c\u4e00\u65f6\u523b\u771f\u7684\u90fd\u5728\u8d70\u201d\u3002\u5355\u6838\u673a\u5668\u4e0a\u7684\u591a\u4efb\u52a1\u9760\u7684\u662f\u5207\u6362&#xff0c;\u5207\u6362\u5f97\u8db3\u591f\u5feb&#xff0c;\u7528\u6237\u5c31\u4f1a\u89c9\u5f97\u5b83\u4eec\u5728\u540c\u65f6\u8fd0\u884c\u3002<\/p>\n<p>\u4f18\u5148\u7ea7\u53ea\u5728\u7ade\u4e89\u65f6\u624d\u6709\u610f\u4e49\u3002CPU \u7a7a\u95f2\u65f6&#xff0c;\u4f18\u5148\u7ea7\u518d\u9ad8\u4e5f\u4e0d\u4f1a\u8ba9\u7a0b\u5e8f\u8dd1\u5f97\u66f4\u5feb&#xff0c;\u56e0\u4e3a\u6839\u672c\u6ca1\u6709\u522b\u7684\u4efb\u52a1\u5728\u62a2\u3002<\/p>\n<h3>2. \u4f18\u5148\u7ea7\u4e0d\u662f\u6743\u9650<\/h3>\n<p>\u8fd9\u4e24\u4e2a\u6982\u5ff5\u5f88\u5bb9\u6613\u6df7\u6dc6&#xff0c;\u4e00\u5b9a\u8981\u8fa8\u6790\u6e05\u695a&#xff1a;<\/p>\n<table>\n<tr>\u7ef4\u5ea6\u4f18\u5148\u7ea7\u6743\u9650<\/tr>\n<tbody>\n<tr>\n<td>\u56de\u7b54\u7684\u95ee\u9898<\/td>\n<td>\u8c01\u5148\u83b7\u5f97 CPU<\/td>\n<td>\u80fd\u4e0d\u80fd\u8bbf\u95ee\u67d0\u4e2a\u8d44\u6e90<\/td>\n<\/tr>\n<tr>\n<td>\u4e3b\u8981\u4f9d\u636e<\/td>\n<td>nice \u503c\u3001PRI\u3001\u8c03\u5ea6\u7b56\u7565<\/td>\n<td>UID\u3001GID\u3001rwx\u3001capabilities<\/td>\n<\/tr>\n<tr>\n<td>\u8c03\u6574\u65b9\u5f0f<\/td>\n<td>nice\u3001renice\u3001setpriority<\/td>\n<td>chmod\u3001chown\u3001\u80fd\u529b\u4f4d<\/td>\n<\/tr>\n<tr>\n<td>\u8fb9\u754c<\/td>\n<td>\u9ad8\u4f18\u5148\u7ea7\u4e0d\u80fd\u7ed5\u8fc7\u6743\u9650\u68c0\u67e5<\/td>\n<td>\u6743\u9650\u9ad8\u4e0d\u81ea\u52a8\u83b7\u5f97\u66f4\u591a CPU<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6743\u9650\u4f4e\u7684\u8fdb\u7a0b&#xff0c;\u4ecd\u7136\u53ef\u4ee5\u8bfb\u53d6\u5b83\u672c\u6765\u5c31\u6709\u6743\u8bfb\u53d6\u7684\u6587\u4ef6&#xff1b;\u6743\u9650\u9ad8\u7684\u666e\u901a\u8fdb\u7a0b&#xff0c;\u4e5f\u6253\u4e0d\u5f00\u81ea\u5df1\u6ca1\u6709\u6743\u9650\u7684\u6587\u4ef6\u3002Linux \u5728\u5224\u65ad\u8d44\u6e90\u8bbf\u95ee\u65f6&#xff0c;\u770b\u7684\u662f\u8fdb\u7a0b\u643a\u5e26\u7684\u7528\u6237\u8eab\u4efd&#xff08;UID&#xff09;&#xff0c;\u800c\u4e0d\u662f\u5b83\u7684\u8c03\u5ea6\u4f18\u5148\u7ea7\u3002<\/p>\n<p>\u628a\u8fd9\u4e24\u4ef6\u4e8b\u5206\u5f00&#xff0c;\u540e\u9762\u770b PRI\u3001NI \u548c\u8c03\u5ea6\u961f\u5217\u65f6\u5c31\u4e0d\u5bb9\u6613\u4e32\u7ebf\u3002<\/p>\n<h2>\u4e8c\u3001PRI\u3001NI \u4e0e nice<\/h2>\n<h3>1. ps \u91cc\u7684 PRI \u548c NI<\/h3>\n<p>\u5148\u770b\u4e00\u4e2a\u6700\u5e38\u7528\u7684\u547d\u4ee4&#xff1a;<\/p>\n<p><span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-l<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token variable\">$$<\/span><\/p>\n<p>\u8f93\u51fa\u5927\u81f4\u5982\u4e0b&#xff0c;PID \u4f1a\u968f\u73af\u5883\u53d8\u5316&#xff1a;<\/p>\n<p>F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD<br \/>\n0 S  1000  4217  4216  0  80   0 &#8211;  2780 wait   pts\/0    00:00:00 bash<\/p>\n<p>\u8fd9\u4e00\u884c\u91cc&#xff0c;UID\u3001PID\u3001PPID\u3001PRI\u3001NI \u6700\u503c\u5f97\u5173\u6ce8\u3002\u548c\u4f18\u5148\u7ea7\u76f4\u63a5\u76f8\u5173\u7684\u662f\u4e24\u4e2a\u5b57\u6bb5&#xff1a;<\/p>\n<ul>\n<li>NI&#xff1a;nice \u503c&#xff0c;\u8868\u793a\u8fdb\u7a0b\u4f18\u5148\u7ea7\u7684\u4fee\u6b63\u91cf\u3002<\/li>\n<li>PRI&#xff1a;\u8c03\u5ea6\u5668\u4f7f\u7528\u7684\u4f18\u5148\u7ea7\u663e\u793a\u503c\u3002\u6570\u503c\u8d8a\u5c0f&#xff0c;\u8d8a\u65e9\u88ab\u8c03\u5ea6\u3002<\/li>\n<\/ul>\n<p>PRI \u4e0d\u662f\u6743\u9650&#xff0c;\u4e5f\u4e0d\u662f\u8fdb\u7a0b\u7684\u201c\u91cd\u8981\u7a0b\u5ea6\u8bc4\u5206\u201d&#xff0c;\u5b83\u53ea\u662f\u8c03\u5ea6\u987a\u5e8f\u7684\u4e00\u4e2a\u6570\u5b57\u8868\u793a\u3002<\/p>\n<h3>2. nice \u662f\u4fee\u6b63\u503c&#xff0c;\u4e0d\u662f\u4f18\u5148\u7ea7\u672c\u8eab<\/h3>\n<p>nice \u7684\u53d6\u503c\u8303\u56f4\u662f -20 \u5230 19&#xff0c;\u4e00\u5171 40 \u4e2a\u7ea7\u522b\u3002\u9ed8\u8ba4\u503c\u662f 0\u3002<\/p>\n<p>\u5b83\u7684\u540d\u5b57\u5f88\u5f62\u8c61&#xff1a;nice \u503c\u8d8a\u9ad8&#xff0c;\u8fdb\u7a0b\u5bf9\u522b\u7684\u8fdb\u7a0b\u8d8a\u201c\u5ba2\u6c14\u201d&#xff0c;\u8d8a\u613f\u610f\u628a CPU \u8ba9\u51fa\u6765&#xff0c;\u6240\u4ee5\u4f18\u5148\u7ea7\u8d8a\u4f4e&#xff1b;nice \u503c\u8d8a\u4f4e&#xff0c;\u8fdb\u7a0b\u8d8a\u201c\u4e0d\u5ba2\u6c14\u201d&#xff0c;\u4f18\u5148\u7ea7\u8d8a\u9ad8\u3002<\/p>\n<p>\u5728\u5e38\u89c1\u7684 ps \u663e\u793a\u53e3\u5f84\u4e0b&#xff0c;\u666e\u901a\u8fdb\u7a0b\u7684\u57fa\u51c6\u4f18\u5148\u7ea7\u53ef\u4ee5\u5199\u6210&#xff1a;<\/p>\n<p>PRI &#061; 80 &#043; nice<\/p>\n<p>\u5982\u679c\u628a 80 \u770b\u4f5c\u57fa\u51c6\u503c&#xff0c;\u4e5f\u53ef\u4ee5\u5199\u6210 PRI(new) &#061; PRI(old) &#043; nice\u3002\u8fd9\u91cc\u7684 PRI(old) \u662f\u57fa\u51c6\u4f18\u5148\u7ea7&#xff0c;\u4e0d\u662f\u4e0a\u4e00\u6b21 renice \u4e4b\u540e\u7684\u7ed3\u679c\u3002\u91cd\u590d\u6267\u884c renice \u662f\u8986\u76d6 nice \u503c&#xff0c;\u4e0d\u662f\u628a\u5dee\u503c\u4e00\u6b21\u6b21\u7d2f\u52a0\u3002<\/p>\n<p>\u4e0d\u540c\u7684\u5de5\u5177\u4f1a\u7528\u4e0d\u540c\u7684\u523b\u5ea6\u663e\u793a\u540c\u4e00\u4e2a\u8c03\u5ea6\u503e\u5411&#xff1a;<\/p>\n<table>\n<tr>\u663e\u793a\u6216\u5185\u6838\u53e3\u5f84nice &#061; 0nice &#061; -20nice &#061; 19\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>ps -l \u7684 PRI<\/td>\n<td>80<\/td>\n<td>60<\/td>\n<td>99<\/td>\n<td>\u5e38\u89c1\u7684 procps \u663e\u793a\u65b9\u5f0f&#xff0c;80 &#043; nice<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u6838\u666e\u901a\u4f18\u5148\u7ea7<\/td>\n<td>120<\/td>\n<td>100<\/td>\n<td>139<\/td>\n<td>O(1) \u8c03\u5ea6\u961f\u5217\u7684\u4e0b\u6807&#xff0c;120 &#043; nice<\/td>\n<\/tr>\n<tr>\n<td>top \u7684 PR<\/td>\n<td>20<\/td>\n<td>0<\/td>\n<td>39<\/td>\n<td>\u53e6\u4e00\u5957\u663e\u793a\u53e3\u5f84&#xff1b;\u5b9e\u65f6\u4efb\u52a1\u53ef\u80fd\u663e\u793a\u4e3a\u8d1f\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8868\u91cc\u8fd9\u4e09\u5957\u6570\u5b57\u4e0d\u4e00\u6837&#xff0c;\u65b9\u5411\u662f\u4e00\u81f4\u7684&#xff1a;\u6570\u503c\u8d8a\u5c0f&#xff0c;\u4f18\u5148\u7ea7\u8d8a\u9ad8\u3002\u5199\u76d1\u63a7\u811a\u672c\u65f6&#xff0c;\u4e0d\u8981\u628a top \u7684 PR \u548c ps \u7684 PRI \u76f4\u63a5\u653e\u5728\u4e00\u8d77\u6bd4\u8f83&#xff0c;\u5b83\u4eec\u4e0d\u662f\u540c\u4e00\u628a\u5c3a\u5b50\u3002\u8c03\u5ea6\u5668\u6700\u7ec8\u6bd4\u8f83\u7684&#xff0c;\u662f task_struct \u91cc\u7684\u6574\u6570\u5b57\u6bb5&#xff1b;ps \u548c top \u53ea\u662f\u628a\u8fd9\u4e9b\u5b57\u6bb5\u7ffb\u8bd1\u6210\u4e0d\u540c\u7684\u663e\u793a\u53e3\u5f84\u3002<\/p>\n<p>ps \u81ea\u5df1\u7684\u4e0d\u540c\u8f93\u51fa\u683c\u5f0f\u4e5f\u53ef\u80fd\u6362\u523b\u5ea6&#xff1a;ps -l \u5e38\u89c1\u7684\u662f 80 \u57fa\u51c6&#xff0c;ps -o pri \u53ef\u80fd\u7ed9\u51fa\u53e6\u4e00\u7ec4\u503c\u3002\u770b\u5230 PRI \u5217\u65f6\u5148\u786e\u8ba4\u547d\u4ee4\u7528\u7684\u662f\u54ea\u79cd\u683c\u5f0f&#xff0c;\u4e0d\u8981\u8de8\u683c\u5f0f\u5957 80 &#043; nice\u3002<\/p>\n<p>\u5185\u6838\u5185\u90e8\u8fd8\u53ef\u80fd\u6839\u636e\u4efb\u52a1\u7684\u7761\u7720\u548c\u8fd0\u884c\u884c\u4e3a\u505a\u52a8\u6001\u4fee\u6b63&#xff0c;\u4f46\u7528\u6237\u8bbe\u7f6e\u7684 nice \u59cb\u7ec8\u662f\u57fa\u51c6\u4fee\u6b63\u91cf\u3002\u8fd9\u79cd\u4fee\u6b63\u901a\u5e38\u6709\u4e0a\u9650&#xff0c;\u5426\u5219\u8fdb\u7a0b\u53ef\u4ee5\u9760\u523b\u610f\u7761\u7720\u3001\u5524\u9192\u6765\u64cd\u7eb5\u81ea\u5df1\u7684\u4f18\u5148\u7ea7\u3002\u4e0d\u540c\u5185\u6838\u7248\u672c\u7684\u52a8\u6001\u89c4\u5219\u4e0d\u540c&#xff0c;\u770b\u8c03\u5ea6\u884c\u4e3a\u65f6\u8981\u4ee5\u5bf9\u5e94\u7248\u672c\u7684\u5b9e\u73b0\u4e3a\u51c6\u3002<\/p>\n<h3>3. \u4f18\u5148\u7ea7\u8303\u56f4\u4e0e\u9965\u997f<\/h3>\n<p>\u5728 ps \u7684\u666e\u901a\u8fdb\u7a0b\u53e3\u5f84\u4e0b&#xff0c;PRI \u843d\u5728 60 \u5230 99 \u4e4b\u95f4&#xff0c;\u5bf9\u5e94 nice \u7684 -20 \u5230 19\u3002\u5185\u6838\u961f\u5217\u91cc\u5219\u662f 100 \u5230 139\u3002\u4e24\u5957\u523b\u5ea6\u5404\u6709 40 \u4e2a\u7ea7\u522b&#xff0c;\u6570\u503c\u4e0a\u76f8\u5dee 40\u3002<\/p>\n<p>\u4f18\u5148\u7ea7\u5dee\u8ddd\u8fc7\u5927\u65f6&#xff0c;\u4f4e\u4f18\u5148\u7ea7\u8fdb\u7a0b\u53ef\u80fd\u957f\u65f6\u95f4\u62a2\u4e0d\u5230 CPU&#xff0c;\u8fd9\u5c31\u662f\u8fdb\u7a0b\u9965\u997f\u3002<\/p>\n<p>nice \u53ea\u662f\u4e00\u79cd\u201c\u504f\u5411\u201d&#xff0c;\u4e0d\u662f\u786c\u5b9e\u65f6\u4fdd\u8bc1\u3002\u628a\u666e\u901a\u8fdb\u7a0b\u7684 nice \u8c03\u5230 -20&#xff0c;\u4e5f\u4e0d\u4f1a\u628a\u5b83\u53d8\u6210\u5b9e\u65f6\u4efb\u52a1\u3002\u5b9e\u65f6\u7b56\u7565&#xff08;\u5982 SCHED_FIFO\u3001SCHED_RR&#xff09;\u4f7f\u7528\u53e6\u4e00\u6bb5\u4f18\u5148\u7ea7\u533a\u95f4&#xff0c;\u5b9e\u65f6\u4efb\u52a1\u4f1a\u6392\u5728\u6240\u6709\u666e\u901a\u4efb\u52a1\u4e4b\u524d\u3002\u9664\u975e\u786e\u5b9e\u9700\u8981\u4f4e\u5ef6\u8fdf\u4fdd\u969c&#xff0c;\u5426\u5219\u4e0d\u8981\u7528\u6781\u7aef nice \u503c\u53bb\u6a21\u62df\u5b9e\u65f6\u884c\u4e3a&#xff0c;\u5bb9\u6613\u628a\u7cfb\u7edf\u91cc\u5176\u4ed6\u4efb\u52a1\u997f\u6b7b\u3002<\/p>\n<h2>\u4e09\u3001\u67e5\u770b\u4e0e\u8c03\u6574\u4f18\u5148\u7ea7<\/h2>\n<h3>1. \u7528 ps \u548c top \u89c2\u5bdf<\/h3>\n<p>\u67e5\u770b\u67d0\u4e2a\u8fdb\u7a0b\u7684 nice \u548c PRI&#xff1a;<\/p>\n<p><span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-l<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">4301<\/span><\/p>\n<p>\u6301\u7eed\u89c2\u5bdf&#xff1a;<\/p>\n<p><span class=\"token function\">top<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">4301<\/span><\/p>\n<p>top \u91cc\u7684 PR \u662f\u4f18\u5148\u7ea7\u663e\u793a\u503c&#xff0c;NI \u662f nice \u503c\u3002\u9ed8\u8ba4\u666e\u901a\u8fdb\u7a0b\u901a\u5e38\u663e\u793a PR &#061; 20\u3001NI &#061; 0&#xff0c;\u8fd9\u548c ps \u7684 80 \u662f\u4e24\u5957\u523b\u5ea6\u3002<\/p>\n<p>\u5728 top \u91cc\u6309 r&#xff0c;\u8f93\u5165\u8fdb\u7a0b PID&#xff0c;\u518d\u8f93\u5165\u65b0\u7684 nice \u503c&#xff0c;\u5c31\u53ef\u4ee5\u8c03\u6574\u5df2\u6709\u8fdb\u7a0b&#xff0c;\u6548\u679c\u7b49\u540c\u4e8e\u6267\u884c\u4e00\u6b21 renice\u3002<\/p>\n<h3>2. \u7528 nice \u548c renice \u8c03\u6574<\/h3>\n<p>\u542f\u52a8\u4e00\u4e2a\u65b0\u8fdb\u7a0b\u65f6\u76f4\u63a5\u6307\u5b9a nice&#xff1a;<\/p>\n<p><span class=\"token function\">nice<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token number\">10<\/span> .\/cpu_task<\/p>\n<p>nice -n 10 \u8868\u793a\u4ee5 nice 10 \u542f\u52a8&#xff0c;\u4f18\u5148\u7ea7\u6bd4\u9ed8\u8ba4\u503c\u4f4e\u3002\u9002\u5408\u7f16\u8bd1\u3001\u5907\u4efd\u3001\u6279\u5904\u7406\u8fd9\u7c7b\u201c\u53ef\u4ee5\u6162\u4e00\u70b9&#xff0c;\u4f46\u522b\u6321\u4f4f\u4ea4\u4e92\u201d\u7684\u4efb\u52a1\u3002<\/p>\n<p>\u8c03\u6574\u5df2\u7ecf\u8fd0\u884c\u7684\u8fdb\u7a0b&#xff1a;<\/p>\n<p><span class=\"token function\">renice<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token number\">5<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">4301<\/span><\/p>\n<p>\u6b63\u6570\u8868\u793a\u964d\u4f4e\u4f18\u5148\u7ea7\u3002\u8981\u8c03\u9ad8\u4f18\u5148\u7ea7&#xff0c;\u9700\u8981\u8d1f\u7684 nice \u503c&#xff1a;<\/p>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">renice<\/span> <span class=\"token parameter variable\">-n<\/span> <span class=\"token parameter variable\">-5<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token number\">4301<\/span><\/p>\n<p>\u666e\u901a\u7528\u6237\u901a\u5e38\u53ea\u80fd\u628a nice \u8c03\u5927&#xff0c;\u4e5f\u5c31\u662f\u4e3b\u52a8\u964d\u4f4e\u4f18\u5148\u7ea7&#xff1b;\u628a nice \u8c03\u5c0f\u9700\u8981 root \u6216 CAP_SYS_NICE \u80fd\u529b&#xff0c;\u67d0\u4e9b\u73af\u5883\u8fd8\u4f1a\u53d7\u5230 RLIMIT_NICE&#xff08;\u8d44\u6e90\u9650\u5236&#xff09;\u7684\u7ea6\u675f\u3002\u628a nice \u4ece 0 \u8c03\u5230 10 \u540e&#xff0c;\u666e\u901a\u7528\u6237\u4e00\u822c\u4e0d\u80fd\u81ea\u5df1\u518d\u8c03\u56de 0\u3002<\/p>\n<p>renice \u4e5f\u53ef\u4ee5\u6309\u8fdb\u7a0b\u7ec4\u6216\u7528\u6237\u6279\u91cf\u64cd\u4f5c&#xff0c;\u5206\u522b\u4f7f\u7528 -g \u548c -u\u3002\u6279\u91cf\u8c03\u6574\u524d\u5148\u786e\u8ba4\u5f71\u54cd\u8303\u56f4&#xff0c;\u5c24\u5176\u662f\u4e0d\u8981\u628a\u7cfb\u7edf\u670d\u52a1\u4e00\u8d77\u964d\u6743\u3002<\/p>\n<h3>3. \u7528\u7cfb\u7edf\u8c03\u7528\u8bfb\u53d6\u548c\u8bbe\u7f6e<\/h3>\n<p>\u9700\u8981\u5728\u7a0b\u5e8f\u91cc\u8bfb\u53d6\u6216\u8bbe\u7f6e nice&#xff0c;\u53ef\u4ee5\u4f7f\u7528 getpriority \u548c setpriority&#xff1a;<\/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;sys\/resource.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;errno.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;stdio.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    errno <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> prio <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">getpriority<\/span><span class=\"token punctuation\">(<\/span>PRIO_PROCESS<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>prio <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span> <span class=\"token operator\">&amp;&amp;<\/span> errno <span class=\"token operator\">!&#061;<\/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;getpriority&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/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;nice &#061; %d\\\\n&#034;<\/span><span class=\"token punctuation\">,<\/span> prio<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">setpriority<\/span><span class=\"token punctuation\">(<\/span>PRIO_PROCESS<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/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;setpriority&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token number\">1<\/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<p>\u7f16\u8bd1\u5e76\u8fd0\u884c&#xff1a;<\/p>\n<p>gcc <span class=\"token parameter variable\">-Wall<\/span> <span class=\"token parameter variable\">-Wextra<\/span> <span class=\"token parameter variable\">-o<\/span> prio_demo prio_demo.c<br \/>\n.\/prio_demo<\/p>\n<p>\u51e0\u4e2a\u53c2\u6570\u7684\u542b\u4e49&#xff1a;<\/p>\n<ul>\n<li>which \u53ef\u4ee5\u662f PRIO_PROCESS\u3001PRIO_PGRP \u6216 PRIO_USER&#xff0c;\u5206\u522b\u8868\u793a\u6309\u8fdb\u7a0b\u3001\u8fdb\u7a0b\u7ec4\u3001\u7528\u6237\u64cd\u4f5c\u3002<\/li>\n<li>who \u4e3a 0 \u65f6\u8868\u793a\u5f53\u524d\u8fdb\u7a0b\u3001\u5f53\u524d\u8fdb\u7a0b\u7ec4\u6216\u5f53\u524d\u7528\u6237\u3002<\/li>\n<li>getpriority \u8fd4\u56de\u7684\u662f nice \u503c&#xff0c;\u4e0d\u662f ps \u91cc\u7684 PRI\u3002\u4e0d\u8981\u62ff\u8fd4\u56de\u503c\u548c 80 \u76f4\u63a5\u6bd4\u8f83\u3002<\/li>\n<li>getpriority \u5931\u8d25\u65f6\u8fd4\u56de -1&#xff0c;\u4f46\u5408\u6cd5\u7684 nice \u503c\u4e5f\u53ef\u80fd\u662f -1&#xff0c;\u6240\u4ee5\u8c03\u7528\u524d\u8981\u628a errno \u6e05\u96f6&#xff0c;\u8fd4\u56de\u540e\u518d\u68c0\u67e5 errno\u3002<\/li>\n<\/ul>\n<p>\u628a nice \u8c03\u5927\u901a\u5e38\u4e0d\u9700\u8981\u7279\u6743&#xff1b;\u628a nice \u8c03\u5c0f\u3001\u63d0\u9ad8\u4f18\u5148\u7ea7&#xff0c;\u4ecd\u7136\u9700\u8981\u76f8\u5e94\u7684\u6743\u9650\u3002<\/p>\n<p>\u5b98\u65b9\u624b\u518c\u5bf9\u8fd9\u4e24\u4e2a\u63a5\u53e3\u7684\u8fd4\u56de\u503c\u548c\u9519\u8bef\u7801\u5199\u5f97\u5f88\u6e05\u695a&#xff0c;\u53ef\u4ee5\u67e5\u9605 getpriority(2)\u3002<\/p>\n<h3>4. \u8c03\u6574\u4f18\u5148\u7ea7\u7684\u8fb9\u754c<\/h3>\n<p>nice \u53ea\u5f71\u54cd CPU \u65f6\u95f4\u7684\u7ade\u4e89&#xff0c;\u4e0d\u89e3\u51b3 I\/O \u74f6\u9888\u3002\u78c1\u76d8\u8bfb\u5199\u6162\u3001\u7f51\u7edc\u7b49\u5f85\u957f&#xff0c;\u8c03 nice \u6ca1\u6709\u7528&#xff0c;\u8fd9\u65f6\u8981\u770b I\/O \u4f18\u5148\u7ea7\u6216\u5b58\u50a8\u672c\u8eab\u7684\u541e\u5410\u3002I\/O \u4f18\u5148\u7ea7\u662f\u53e6\u4e00\u5957\u673a\u5236&#xff0c;\u6548\u679c\u8fd8\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684 I\/O \u8c03\u5ea6\u5668\u3002<\/p>\n<p>\u5728\u5bb9\u5668\u91cc&#xff0c;nice \u8fd8\u8981\u548c cgroup&#xff08;\u63a7\u5236\u7ec4&#xff09;\u7684 CPU \u6743\u91cd\u3001\u914d\u989d\u4e00\u8d77\u770b\u3002\u5bb9\u5668\u5185\u628a\u8fdb\u7a0b\u8c03\u6210\u9ad8\u4f18\u5148\u7ea7&#xff0c;\u4e0d\u4f1a\u7a81\u7834\u4e0a\u5c42\u8bbe\u7f6e\u7684 CPU \u9650\u989d&#xff1b;\u5b83\u53ea\u662f\u6539\u53d8\u540c\u4e00\u63a7\u5236\u7ec4\u5185\u7684\u7ade\u4e89\u987a\u5e8f\u3002<\/p>\n<p>\u53e6\u5916&#xff0c;\u8d1f nice \u503c\u4e0d\u662f\u201c\u6027\u80fd\u5f00\u5173\u201d\u3002\u4e00\u4e2a CPU \u5bc6\u96c6\u578b\u4efb\u52a1\u5373\u4f7f\u62ff\u5230\u6700\u9ad8\u666e\u901a\u4f18\u5148\u7ea7&#xff0c;\u4e5f\u53ea\u662f\u5728\u7ade\u4e89\u65f6\u66f4\u65e9\u3001\u66f4\u9891\u7e41\u5730\u62ff\u5230 CPU&#xff0c;\u4e0d\u4f1a\u63d0\u9ad8\u5355\u6838\u672c\u8eab\u7684\u8ba1\u7b97\u901f\u5ea6\u3002\u771f\u6b63\u9700\u8981\u4f4e\u5ef6\u8fdf\u65f6&#xff0c;\u5e94\u8be5\u8003\u8651\u5b9e\u65f6\u8c03\u5ea6\u7b56\u7565&#xff0c;\u5e76\u540c\u65f6\u8bc4\u4f30\u5b83\u5bf9\u7cfb\u7edf\u5176\u4ed6\u4efb\u52a1\u7684\u5f71\u54cd\u3002<\/p>\n<h2>\u56db\u3001\u8fdb\u7a0b\u5207\u6362&#xff1a;\u4fdd\u5b58\u4e00\u4efd&#xff0c;\u6062\u590d\u53e6\u4e00\u4efd<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104104903-6aeb0d9f6e227.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>1. \u65f6\u95f4\u7247\u8ba9 CPU \u80fd\u88ab\u6536\u56de<\/h3>\n<p>\u666e\u901a\u7684\u73b0\u4ee3\u5206\u65f6\u7cfb\u7edf\u4e2d&#xff0c;\u4e00\u4e2a\u8fdb\u7a0b\u5373\u4f7f\u5199\u4e86\u6b7b\u5faa\u73af&#xff0c;\u4e5f\u4e0d\u4f1a\u6c38\u8fdc\u5360\u7740 CPU \u4e0d\u653e&#xff1a;<\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">void<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">(<\/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 punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u6bb5\u7a0b\u5e8f\u4f1a\u4e00\u76f4\u5904\u4e8e\u53ef\u8fd0\u884c\u72b6\u6001&#xff0c;\u4f46\u5185\u6838\u4f1a\u5728\u65f6\u949f\u4e2d\u65ad\u5230\u6765\u65f6\u68c0\u67e5\u5b83\u662f\u5426\u5df2\u7ecf\u7528\u5b8c\u65f6\u95f4\u7247\u3002\u65f6\u95f4\u7247\u5230\u4e86&#xff0c;\u5c31\u628a CPU \u6536\u8d70&#xff0c;\u6362\u53e6\u4e00\u4e2a\u4efb\u52a1\u8fd0\u884c\u3002\u6b7b\u5faa\u73af\u8fdb\u7a0b\u4f1a\u8ba9\u4e00\u4e2a\u6838\u5fc3\u8dd1\u6ee1&#xff0c;\u4f46\u4e0d\u4f1a\u8ba9\u6574\u53f0\u673a\u5668\u5931\u53bb\u54cd\u5e94\u3002<\/p>\n<p>\u89e6\u53d1\u5207\u6362\u7684\u5e38\u89c1\u60c5\u51b5\u6709\u4e09\u7c7b&#xff1a;<\/p>\n<ul>\n<li>\u5f53\u524d\u4efb\u52a1\u7684\u65f6\u95f4\u7247\u7528\u5b8c\u3002<\/li>\n<li>\u5f53\u524d\u4efb\u52a1\u4e3b\u52a8\u963b\u585e&#xff0c;\u4f8b\u5982\u7b49\u5f85 I\/O\u3001\u7761\u7720\u6216\u83b7\u53d6\u9501\u3002<\/li>\n<li>\u4e00\u4e2a\u66f4\u9ad8\u4f18\u5148\u7ea7\u7684\u4efb\u52a1\u88ab\u5524\u9192&#xff0c;\u5185\u6838\u51b3\u5b9a\u7acb\u5373\u62a2\u5360\u3002<\/li>\n<\/ul>\n<h3>2. \u4e0a\u4e0b\u6587\u91cc\u6709\u4ec0\u4e48<\/h3>\n<p>CPU \u7684\u5bc4\u5b58\u5668\u53ea\u6709\u4e00\u4efd&#xff0c;\u4f46\u6bcf\u4e2a\u8fdb\u7a0b\u90fd\u6709\u81ea\u5df1\u7684\u201c\u5bc4\u5b58\u5668\u5feb\u7167\u201d\u3002\u5207\u6362\u65f6\u4fdd\u5b58\u7684\u662f CPU \u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u786c\u4ef6\u72b6\u6001&#xff0c;\u4e0d\u662f\u6574\u4e2a\u8fdb\u7a0b\u7684\u5185\u5b58&#xff1a;<\/p>\n<ul>\n<li>\u7a0b\u5e8f\u8ba1\u6570\u5668 PC&#xff0c;\u5728 x86-64 \u4e0a\u662f RIP&#xff0c;\u6307\u5411\u4e0b\u4e00\u6761\u8981\u6267\u884c\u7684\u6307\u4ee4\u3002<\/li>\n<li>\u6808\u6307\u9488 SP&#xff0c;\u6307\u5411\u5f53\u524d\u7528\u6237\u6808\u6216\u5185\u6838\u6808\u3002<\/li>\n<li>\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u4f8b\u5982 RAX\u3001RBX\u3001RCX\u3001RDX\u3002<\/li>\n<li>\u6807\u5fd7\u5bc4\u5b58\u5668&#xff0c;\u4fdd\u5b58\u6761\u4ef6\u7801\u548c\u63a7\u5236\u4f4d\u3002<\/li>\n<li>\u6d6e\u70b9\u3001SIMD \u7b49\u6269\u5c55\u72b6\u6001&#xff0c;\u6309\u9700\u4fdd\u5b58\u3002<\/li>\n<li>\u5730\u5740\u7a7a\u95f4\u76f8\u5173\u72b6\u6001&#xff0c;\u4f8b\u5982\u9875\u8868\u57fa\u5740\u5bc4\u5b58\u5668 CR3\u3002<\/li>\n<\/ul>\n<p>\u53ef\u4ee5\u628a CPU \u60f3\u6210\u4e00\u95f4\u53ea\u80fd\u5750\u4e00\u4e2a\u4eba\u7684\u529e\u516c\u5ba4&#xff0c;\u5bc4\u5b58\u5668\u662f\u4e00\u5f20\u5f20\u684c\u5b50&#xff0c;\u5bc4\u5b58\u5668\u4e2d\u7684\u5185\u5bb9\u5c31\u662f\u684c\u9762\u4e0a\u6b63\u5728\u644a\u5f00\u7684\u7eb8\u3002\u8fdb\u7a0b A \u88ab\u6362\u4e0b\u65f6&#xff0c;\u8981\u628a\u8fd9\u4e9b\u7eb8\u6536\u8fdb A \u81ea\u5df1\u7684\u6587\u4ef6\u888b&#xff1b;\u8fdb\u7a0b B \u4e0a\u6765\u65f6&#xff0c;\u518d\u628a B \u7684\u6587\u4ef6\u888b\u644a\u5f00\u3002\u684c\u5b50\u53ea\u6709\u4e00\u5f20&#xff0c;\u6587\u4ef6\u888b\u53ef\u4ee5\u6709\u5f88\u591a\u4e2a\u3002<\/p>\n<h3>3. \u4fdd\u5b58\u5230\u54ea\u91cc<\/h3>\n<p>\u8fdb\u7a0b\u7684\u4e0a\u4e0b\u6587&#xff0c;\u5373\u5404\u7c7b\u5bc4\u5b58\u5668\u7684\u73b0\u573a&#xff0c;\u4e3b\u8981\u4fdd\u5b58\u5728\u88ab\u6362\u51fa\u4efb\u52a1\u81ea\u8eab\u7684\u5185\u6838\u6808\u4e2d\u3002\u4efb\u52a1\u88ab\u6362\u51fa\u65f6&#xff0c;\u5185\u6838\u5c06\u8fd4\u56de\u5730\u5740\u548c\u90e8\u5206\u5bc4\u5b58\u5668\u538b\u5165\u8be5\u4efb\u52a1\u7684\u5185\u6838\u6808&#xff0c;\u5f85\u8be5\u4efb\u52a1\u518d\u6b21\u88ab\u8c03\u5ea6\u65f6\u518d\u4ece\u6808\u4e2d\u6062\u590d\u3002<\/p>\n<p>task_struct \u4e2d\u7528\u4e8e\u4fdd\u5b58\u4e0a\u4e0b\u6587\u7684 thread_struct \u5e76\u4e0d\u5b58\u653e\u8fd9\u4e9b\u901a\u7528\u5bc4\u5b58\u5668&#xff0c;\u5b83\u53ea\u8bb0\u5f55\u82e5\u5e72\u7528\u4e8e\u5b9a\u4f4d\u73b0\u573a\u7684\u5b57\u6bb5&#xff0c;\u5176\u4e2d\u6700\u91cd\u8981\u7684\u662f\u5185\u6838\u6808\u6307\u9488 sp&#xff08;\u6307\u5411\u4e0a\u8ff0\u5185\u6838\u6808&#xff09;&#xff0c;\u6b64\u5916\u8fd8\u6709 FPU \u6d6e\u70b9\u5bc4\u5b58\u5668\u72b6\u6001\u7b49\u3002<\/p>\n<p>\u7b80\u8a00\u4e4b&#xff1a;\u901a\u7528\u5bc4\u5b58\u5668\u7684\u73b0\u573a\u4fdd\u5b58\u5728\u5185\u6838\u6808\u4e0a&#xff0c;\u5185\u6838\u6808\u7684\u4f4d\u7f6e\u4e0e\u6d6e\u70b9\u72b6\u6001\u5219\u7531task_struct \u4e2d\u7684 thread_struct \u8bb0\u5f55\u3002<\/p>\n<p>\u65e9\u671f x86 \u63d0\u4f9b\u786c\u4ef6\u4efb\u52a1\u5207\u6362\u673a\u5236&#xff0c;\u4efb\u52a1\u72b6\u6001\u6bb5 TSS \u4e2d\u4fdd\u5b58\u4efb\u52a1\u7684\u90e8\u5206\u4e0a\u4e0b\u6587&#xff0c;Linux 0.11 \u7684 task_struct \u4e2d\u5373\u53ef\u770b\u5230 tss_struct\u3002\u73b0\u4ee3 Linux \u6539\u7528\u8f6f\u4ef6\u65b9\u5f0f\u5b8c\u6210\u4e0a\u4e0b\u6587\u5207\u6362&#xff0c;TSS \u4ecd\u7136\u4fdd\u7559&#xff0c;\u4f46\u4e3b\u8981\u7528\u4e8e\u5728\u7528\u6237\u6001\u5207\u6362\u5230\u5185\u6838\u6001\u65f6\u63d0\u4f9b\u5185\u6838\u6808\u6307\u9488&#xff0c;\u5df2\u4e0d\u518d\u7528\u4e8e\u4fdd\u5b58\u901a\u7528\u5bc4\u5b58\u5668\u73b0\u573a\u3002<\/p>\n<p>\u5185\u6838\u901a\u8fc7 current \u5b8f\u83b7\u53d6\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684 task_struct\u3002\u8c03\u5ea6\u5668\u9009\u51fa\u4e0b\u4e00\u4e2a\u4efb\u52a1\u540e&#xff0c;\u5c06 current \u5207\u6362\u5230\u65b0\u4efb\u52a1&#xff0c;\u518d\u6062\u590d\u5176\u73b0\u573a\u3002<\/p>\n<h3>4. \u5207\u6362\u7684\u6210\u672c<\/h3>\n<p>\u76f4\u63a5\u6210\u672c\u5305\u62ec\u4fdd\u5b58\u548c\u6062\u590d\u5bc4\u5b58\u5668\u3001\u66f4\u65b0\u8c03\u5ea6\u5668\u6570\u636e\u7ed3\u6784\u3001\u52a0\u9501&#xff0c;\u4ee5\u53ca\u5207\u6362\u5730\u5740\u7a7a\u95f4\u3002\u95f4\u63a5\u6210\u672c\u5f80\u5f80\u66f4\u5927&#xff1a;\u65b0\u4efb\u52a1\u7684\u5de5\u4f5c\u96c6\u53ef\u80fd\u4e0d\u5728 CPU \u7f13\u5b58\u91cc&#xff0c;\u9875\u8868\u548c TLB&#xff08;\u5730\u5740\u8f6c\u6362\u7f13\u5b58&#xff09;\u53ef\u80fd\u9700\u8981\u66f4\u65b0&#xff0c;\u5206\u652f\u9884\u6d4b\u5668\u4e5f\u8981\u91cd\u65b0\u9002\u5e94\u3002\u5207\u6362\u8d8a\u9891\u7e41&#xff0c;\u8fd9\u4e9b\u201c\u91cd\u65b0\u70ed\u8eab\u201d\u7684\u5f00\u9500\u8d8a\u660e\u663e\u3002<\/p>\n<p>\u53ef\u4ee5\u7528 GNU time \u89c2\u5bdf\u4e00\u4e2a\u7a0b\u5e8f\u88ab\u5207\u6362\u4e86\u591a\u5c11\u6b21&#xff1a;<\/p>\n<p>\/usr\/bin\/time <span class=\"token parameter variable\">-v<\/span> .\/cpu_task<\/p>\n<p>\u5982\u679c\u63d0\u793a\u627e\u4e0d\u5230 \/usr\/bin\/time&#xff0c;\u9700\u8981\u5b89\u88c5 GNU time \u5305&#xff1b;shell \u5185\u7f6e\u7684 time \u4e0d\u63d0\u4f9b -v \u9009\u9879\u3002\u8f93\u51fa\u91cc\u6709\u4e24\u884c\u503c\u5f97\u770b&#xff1a;<\/p>\n<ul>\n<li>Voluntary context switches&#xff1a;\u4efb\u52a1\u4e3b\u52a8\u8ba9\u51fa CPU&#xff0c;\u901a\u5e38\u662f\u56e0\u4e3a\u7761\u7720\u3001\u7b49\u5f85 I\/O \u6216\u963b\u585e\u3002<\/li>\n<li>Involuntary context switches&#xff1a;\u4efb\u52a1\u5e76\u4e0d\u60f3\u8d70&#xff0c;\u4f46\u88ab\u65f6\u95f4\u7247\u6216\u66f4\u9ad8\u4f18\u5148\u7ea7\u4efb\u52a1\u62a2\u5360\u4e86\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u4e24\u4e2a\u6570\u5b57\u80fd\u5e2e\u52a9\u5224\u65ad\u5207\u6362\u4e3b\u8981\u6765\u81ea\u963b\u585e\u8fd8\u662f\u62a2\u5360&#xff0c;\u5177\u4f53\u6570\u503c\u4f1a\u968f\u8d1f\u8f7d\u53d8\u5316\u3002\u4e0a\u4e0b\u6587\u5207\u6362\u4e0d\u662f\u8d8a\u5c11\u8d8a\u597d&#xff1a;\u5207\u6362\u592a\u5c11&#xff0c;\u4ea4\u4e92\u5ef6\u8fdf\u53d8\u5dee&#xff1b;\u5207\u6362\u592a\u591a&#xff0c;\u541e\u5410\u91cf\u88ab\u5f00\u9500\u5403\u6389\u3002\u8c03\u5ea6\u5668\u505a\u7684\u5c31\u662f\u5728\u8fd9\u4e24\u8005\u4e4b\u95f4\u627e\u5e73\u8861\u3002<\/p>\n<h2>\u4e94\u3001O(1) \u8c03\u5ea6\u5668&#xff1a;\u5e38\u6570\u65f6\u95f4\u6311\u51fa\u4e0b\u4e00\u4e2a\u8fdb\u7a0b<\/h2>\n<p>\u4e0b\u9762\u8ba8\u8bba\u7684\u662f Linux 2.6 \u65e9\u671f\u4f7f\u7528\u7684 O(1) \u8c03\u5ea6\u5668\u3002\u5b83\u5728 2.6.23 \u4e4b\u540e\u88ab CFS&#xff08;\u5b8c\u5168\u516c\u5e73\u8c03\u5ea6\u5668&#xff09;\u53d6\u4ee3&#xff0c;\u66f4\u65b0\u7684\u5185\u6838\u53c8\u8f6c\u5411 EEVDF&#xff08;Earliest Eligible Virtual Deadline First&#xff09;\u3002\u73b0\u4ee3\u751f\u4ea7\u5185\u6838\u91cc\u4e0d\u4f1a\u76f4\u63a5\u770b\u5230\u8fd9\u5957\u6570\u7ec4&#xff0c;\u4f46\u5b83\u628a\u201c\u4f18\u5148\u7ea7\u961f\u5217 &#043; \u4f4d\u56fe &#043; \u6d3b\u52a8\/\u8fc7\u671f\u53cc\u6570\u7ec4\u201d\u7ec4\u7ec7\u5f97\u5f88\u6e05\u695a&#xff0c;\u4ecd\u7136\u662f\u7406\u89e3\u8c03\u5ea6\u5668\u8bbe\u8ba1\u7684\u597d\u6837\u672c\u3002<\/p>\n<h3>1. \u6bcf\u4e2a CPU \u4e00\u4e2a runqueue<\/h3>\n<p>O(1) \u8c03\u5ea6\u5668\u4e3a\u6bcf\u4e2a CPU \u7ef4\u62a4\u4e00\u4e2a\u8fd0\u884c\u961f\u5217&#xff0c;\u7ed3\u6784\u4f53\u53eb rq\u3002\u51e0\u4e2a\u4e3b\u8981\u5b57\u6bb5\u662f&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">rq<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">long<\/span> nr_running<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">task_struct<\/span> <span class=\"token operator\">*<\/span>curr<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span>idle<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>prev_mm<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">prio_array<\/span> <span class=\"token operator\">*<\/span>active<span class=\"token punctuation\">,<\/span> <span class=\"token operator\">*<\/span>expired<span class=\"token punctuation\">,<\/span> arrays<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">int<\/span> best_expired_prio<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/* &#8230; *\/<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>nr_running \u8bb0\u5f55\u53ef\u8fd0\u884c\u4efb\u52a1\u7684\u6570\u91cf&#xff0c;curr \u662f\u5f53\u524d\u4efb\u52a1&#xff0c;idle \u662f\u7a7a\u95f2\u4efb\u52a1\u3002active \u548c expired \u5206\u522b\u6307\u5411\u6d3b\u52a8\u6570\u7ec4\u548c\u8fc7\u671f\u6570\u7ec4&#xff0c;arrays[2] \u662f\u628a\u8fd9\u4e24\u4e2a\u6570\u7ec4\u653e\u5728\u4e00\u8d77\u7684\u5b58\u50a8\u3002<\/p>\n<p>\u6bcf\u4e2a CPU \u81ea\u5df1\u7ef4\u62a4\u961f\u5217&#xff0c;\u53ef\u4ee5\u51cf\u5c11\u591a\u6838\u4e4b\u95f4\u7684\u9501\u7ade\u4e89\u3002\u591a\u4e2a CPU \u4e4b\u95f4\u8fd8\u8981\u505a SMP&#xff08;\u5bf9\u79f0\u591a\u5904\u7406&#xff09;\u8d1f\u8f7d\u5747\u8861&#xff0c;\u5426\u5219\u4f1a\u51fa\u73b0\u4e00\u4e2a CPU \u5fd9\u5f97\u6392\u961f\u3001\u53e6\u4e00\u4e2a CPU \u7a7a\u95f2\u7684\u60c5\u51b5\u3002\u8d1f\u8f7d\u5747\u8861\u3001\u4efb\u52a1\u8fc1\u79fb\u8fd9\u4e9b\u7ec6\u8282\u4e0d\u5728\u672c\u6587\u5c55\u5f00&#xff0c;\u4f46\u5b83\u4eec\u662f\u201c\u6bcf\u4e2a CPU \u4e00\u4e2a runqueue\u201d\u5e26\u6765\u7684\u76f4\u63a5\u95ee\u9898\u3002<\/p>\n<h3>2. 140 \u4e2a\u4f18\u5148\u7ea7\u961f\u5217<\/h3>\n<p>\u4f18\u5148\u7ea7\u6570\u7ec4 prio_array \u7684\u6838\u5fc3\u662f\u4e00\u4e2a\u957f\u5ea6\u4e3a 140 \u7684\u961f\u5217\u6570\u7ec4&#xff1a;<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">prio_array<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">unsigned<\/span> <span class=\"token keyword\">int<\/span> nr_active<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">DECLARE_BITMAP<\/span><span class=\"token punctuation\">(<\/span>bitmap<span class=\"token punctuation\">,<\/span> MAX_PRIO <span class=\"token operator\">&#043;<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">list_head<\/span> queue<span class=\"token punctuation\">[<\/span>MAX_PRIO<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>queue[140] \u7684\u6bcf\u4e2a\u5143\u7d20\u662f\u4e00\u6761\u94fe\u8868\u7684\u5934\u3002\u6570\u7ec4\u4e0b\u6807\u5c31\u662f\u4f18\u5148\u7ea7&#xff0c;\u76f8\u540c\u4f18\u5148\u7ea7\u7684\u4efb\u52a1\u6309 FIFO&#xff08;\u5148\u8fdb\u5148\u51fa&#xff09;\u6302\u5728\u8fd9\u6761\u94fe\u8868\u4e0a\u3002\u8c03\u5ea6\u65f6\u53d6\u94fe\u8868\u5934\u7684\u4efb\u52a1&#xff0c;\u5165\u961f\u65f6\u6302\u5230\u94fe\u8868\u5c3e\u3002<\/p>\n<p>\u8fd9 140 \u4e2a\u4e0b\u6807\u5206\u6210\u4e24\u6bb5&#xff1a;<\/p>\n<ul>\n<li>0 \u5230 99&#xff1a;\u5b9e\u65f6\u4f18\u5148\u7ea7&#xff0c;\u666e\u901a\u8fdb\u7a0b\u4e0d\u53c2\u4e0e\u3002<\/li>\n<li>100 \u5230 139&#xff1a;\u666e\u901a\u4f18\u5148\u7ea7&#xff0c;\u666e\u901a\u8fdb\u7a0b\u5728\u8fd9\u91cc\u7ade\u4e89\u3002<\/li>\n<\/ul>\n<p>\u666e\u901a\u4efb\u52a1\u7684\u961f\u5217\u4e0b\u6807\u7531 nice \u503c\u51b3\u5b9a&#xff1a;<\/p>\n<p>static_prio &#061; 120 &#043; nice<\/p>\n<p>nice \u4e3a -20 \u65f6\u4e0b\u6807\u662f 100&#xff0c;nice \u4e3a 19 \u65f6\u4e0b\u6807\u662f 139\u3002nice \u8d8a\u5c0f&#xff0c;\u4e0b\u6807\u8d8a\u5c0f&#xff0c;\u8d8a\u65e9\u88ab\u8c03\u5ea6\u5668\u770b\u5230\u3002<\/p>\n<h3>3. bitmap&#xff1a;\u5148\u627e\u961f\u5217&#xff0c;\u518d\u627e\u4efb\u52a1<\/h3>\n<p>\u5982\u679c\u6bcf\u6b21\u90fd\u4ece queue[0] \u5f00\u59cb\u9010\u4e2a\u68c0\u67e5 140 \u4e2a\u961f\u5217&#xff0c;\u867d\u7136\u4e0a\u9650\u56fa\u5b9a&#xff0c;\u4f46\u5e38\u6570\u4ecd\u7136\u504f\u5927\u3002O(1) \u8c03\u5ea6\u5668\u7528\u4e00\u5f20\u4f4d\u56fe\u6765\u52a0\u901f&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u4e00\u4f4d\u5bf9\u5e94\u4e00\u4e2a\u4f18\u5148\u7ea7\u961f\u5217\u3002<\/li>\n<li>\u4f4d\u4e3a 1 \u8868\u793a\u961f\u5217\u975e\u7a7a&#xff0c;\u4e3a 0 \u8868\u793a\u7a7a\u3002<\/li>\n<li>\u627e\u5230\u7b2c\u4e00\u4e2a\u4e3a 1 \u7684\u4f4d&#xff0c;\u5c31\u627e\u5230\u4e86\u5f53\u524d\u6700\u9ad8\u4f18\u5148\u7ea7\u7684\u975e\u7a7a\u961f\u5217\u3002<\/li>\n<\/ul>\n<p>\u5728 32 \u4f4d\u5185\u6838\u4e0a&#xff0c;bitmap[5] \u662f 5 \u4e2a 32 \u4f4d\u5b57&#xff0c;\u4e00\u5171 160 \u4f4d&#xff0c;\u8db3\u591f\u8986\u76d6 140 \u4e2a\u4f18\u5148\u7ea7\u3002\u67e5\u627e\u7b2c\u4e00\u4e2a\u7f6e\u4f4d\u53ef\u4ee5\u7528 sched_find_first_bit \u4e4b\u7c7b\u7684\u539f\u8bed\u5b8c\u6210&#xff0c;\u4e0d\u9700\u8981\u9010\u6761\u904d\u5386\u4efb\u52a1\u94fe\u8868\u3002<\/p>\n<p>\u8fd9\u91cc\u8981\u533a\u5206\u4e24\u4e2a\u201c\u5e38\u6570\u201d&#xff1a;<\/p>\n<ul>\n<li>\u626b\u63cf 140 \u4e2a\u961f\u5217\u7684\u4e0a\u9650\u662f\u56fa\u5b9a\u7684&#xff0c;\u672c\u6765\u5c31\u662f O(1)\u3002<\/li>\n<li>\u4f4d\u56fe\u628a\u67e5\u627e\u6210\u672c\u8fdb\u4e00\u6b65\u538b\u4f4e&#xff0c;\u800c\u4e14\u67e5\u627e\u6210\u672c\u4e0d\u968f\u53ef\u8fd0\u884c\u8fdb\u7a0b\u6570\u91cf\u589e\u957f\u3002<\/li>\n<\/ul>\n<p>O(1) \u63cf\u8ff0\u7684\u662f\u6311\u9009\u6210\u672c\u4e0e\u4efb\u52a1\u6570\u91cf\u65e0\u5173&#xff1a;100 \u4e2a\u4efb\u52a1\u548c 10000 \u4e2a\u4efb\u52a1&#xff0c;\u8c03\u5ea6\u5668\u90fd\u53ea\u9700\u8981\u5728\u4f4d\u56fe\u91cc\u627e\u7b2c\u4e00\u4e2a\u975e\u7a7a\u961f\u5217&#xff0c;\u7136\u540e\u53d6\u94fe\u8868\u5934\u3002<\/p>\n<h3>4. active \u548c expired<\/h3>\n<p>prio_array \u6709\u4e24\u4efd&#xff0c;\u4e00\u4efd\u662f\u6d3b\u52a8\u6570\u7ec4&#xff0c;\u4e00\u4efd\u662f\u8fc7\u671f\u6570\u7ec4&#xff1a;<\/p>\n<ul>\n<li>\u6d3b\u52a8\u6570\u7ec4\u91cc\u7684\u4efb\u52a1\u8fd8\u6709\u5269\u4f59\u65f6\u95f4\u7247&#xff0c;\u53ef\u4ee5\u88ab\u8c03\u5ea6\u3002<\/li>\n<li>\u8fc7\u671f\u6570\u7ec4\u91cc\u7684\u4efb\u52a1\u65f6\u95f4\u7247\u5df2\u7ecf\u7528\u5b8c&#xff0c;\u7b49\u5f85\u4e0b\u4e00\u8f6e\u3002<\/li>\n<\/ul>\n<p>\u5f53\u6d3b\u52a8\u6570\u7ec4\u4e2d\u7684\u4efb\u52a1\u9010\u6e10\u88ab\u5904\u7406\u5b8c&#xff0c;\u8fc7\u671f\u6570\u7ec4\u4f1a\u8d8a\u6765\u8d8a\u6ee1\u3002\u7b49\u6d3b\u52a8\u6570\u7ec4\u7a7a\u4e86&#xff0c;\u5185\u6838\u53ea\u8981\u4ea4\u6362 active \u548c expired \u4e24\u4e2a\u6307\u9488&#xff0c;\u539f\u6765\u7684\u8fc7\u671f\u6570\u7ec4\u5c31\u53d8\u6210\u4e86\u65b0\u7684\u6d3b\u52a8\u6570\u7ec4&#xff1a;<\/p>\n<p><span class=\"token function\">swap<\/span><span class=\"token punctuation\">(<\/span>active<span class=\"token punctuation\">,<\/span> expired<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u4e0d\u662f\u628a 140 \u6761\u94fe\u8868\u6574\u4f53\u642c\u8fc7\u53bb&#xff0c;\u53ea\u662f\u4ea4\u6362\u4e24\u4e2a\u6307\u9488\u3002\u6362\u5165\u7684\u4efb\u52a1\u4f1a\u91cd\u65b0\u8ba1\u7b97\u65f6\u95f4\u7247&#xff0c;\u83b7\u5f97\u4e0b\u4e00\u8f6e\u8fd0\u884c\u673a\u4f1a\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104104905-6aeb0da1dac31.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8fd9\u79cd\u53cc\u6570\u7ec4\u8bbe\u8ba1\u8ba9\u201c\u7528\u5b8c\u65f6\u95f4\u7247\u7684\u4efb\u52a1\u201d\u548c\u201c\u8fd8\u6709\u65f6\u95f4\u7247\u7684\u4efb\u52a1\u201d\u81ea\u7136\u5206\u5f00\u3002\u8c03\u5ea6\u5668\u4e0d\u9700\u8981\u5728\u6bcf\u4e2a\u4efb\u52a1\u4e0a\u53cd\u590d\u8ba1\u7b97\u201c\u662f\u5426\u8fd8\u6709\u914d\u989d\u201d&#xff0c;\u53ea\u8981\u770b\u4e24\u4e2a\u6570\u7ec4\u7684\u72b6\u6001\u5373\u53ef\u3002<\/p>\n<h3>5. \u4e3a\u4ec0\u4e48\u53eb O(1)<\/h3>\n<p>\u628a\u4e00\u6b21\u8c03\u5ea6\u62c6\u5f00\u770b&#xff1a;<\/p>\n<li>\u4ece\u5f53\u524d CPU \u7684 rq \u91cc\u53d6\u6d3b\u52a8\u6570\u7ec4\u3002<\/li>\n<li>\u5728 bitmap \u4e2d\u627e\u7b2c\u4e00\u4e2a\u7f6e 1 \u7684\u4f4d\u3002<\/li>\n<li>\u53d6\u5bf9\u5e94 queue \u7684\u94fe\u8868\u5934\u3002<\/li>\n<li>\u5982\u679c\u9009\u4e2d\u4efb\u52a1\u4e0d\u662f\u5f53\u524d\u4efb\u52a1&#xff0c;\u8fdb\u5165\u4e0a\u4e0b\u6587\u5207\u6362\u3002<\/li>\n<p>\u5165\u961f\u548c\u51fa\u961f\u90fd\u662f\u94fe\u8868\u64cd\u4f5c&#xff0c;\u67e5\u627e\u961f\u5217\u662f\u4f4d\u56fe\u64cd\u4f5c&#xff0c;\u6574\u4e2a\u8fc7\u7a0b\u4e0d\u968f\u53ef\u8fd0\u884c\u4efb\u52a1\u6570\u91cf\u7ebf\u6027\u589e\u957f&#xff0c;\u6240\u4ee5\u88ab\u79f0\u4e3a O(1) \u8c03\u5ea6\u7b97\u6cd5\u3002<\/p>\n<p>\u4f46 O(1) \u4e0d\u7b49\u4e8e\u96f6\u6210\u672c\u3002\u8c03\u5ea6\u5668\u4ecd\u7136\u8981\u52a0\u9501\u3001\u7ef4\u62a4 nr_running\u3001\u5904\u7406\u4f18\u5148\u7ea7\u53d8\u5316\u3001\u505a SMP \u8d1f\u8f7d\u5747\u8861&#xff0c;\u8fd8\u8981\u5728\u65f6\u95f4\u7247\u7528\u5b8c\u65f6\u628a\u4efb\u52a1\u4ece\u6d3b\u52a8\u6570\u7ec4\u79fb\u5230\u8fc7\u671f\u6570\u7ec4\u3002O(1) \u63cf\u8ff0\u7684\u662f\u201c\u9009\u62e9\u4e0b\u4e00\u4e2a\u4efb\u52a1\u7684\u7b97\u6cd5\u590d\u6742\u5ea6\u201d&#xff0c;\u4e0d\u662f\u6574\u4e2a\u7cfb\u7edf\u7684\u5f00\u9500\u3002<\/p>\n<h3>6. \u5386\u53f2\u5b9a\u4f4d\u4e0e\u5c40\u9650<\/h3>\n<p>O(1) \u8c03\u5ea6\u5668\u5728 Linux 2.6 \u65e9\u671f\u89e3\u51b3\u4e86\u5f53\u65f6\u8c03\u5ea6\u5668\u5728\u8fdb\u7a0b\u6570\u91cf\u589e\u5927\u65f6\u53d8\u6162\u7684\u95ee\u9898\u3002\u5b83\u9700\u8981\u6839\u636e\u4efb\u52a1\u7684\u7761\u7720\u548c\u8fd0\u884c\u884c\u4e3a\u5224\u65ad\u201c\u4ea4\u4e92\u6027\u201d&#xff0c;\u5e76\u7ed9\u4ea4\u4e92\u578b\u4efb\u52a1\u4e00\u5b9a\u7684\u4f18\u5148\u7ea7\u8865\u507f\u3002\u8fd9\u4e9b\u542f\u53d1\u5f0f\u89c4\u5219\u5728\u8d1f\u8f7d\u53d8\u5316\u65f6\u5bb9\u6613\u5224\u65ad\u5931\u8bef&#xff0c;\u516c\u5e73\u6027\u548c\u5ef6\u8fdf\u4e4b\u95f4\u7684\u5e73\u8861\u4e5f\u4e0d\u591f\u7406\u60f3\u3002<\/p>\n<p>Linux 2.6.23 \u5f15\u5165\u4e86 CFS&#xff0c;\u7528\u865a\u62df\u8fd0\u884c\u65f6\u95f4\u548c\u7ea2\u9ed1\u6811\u6765\u7ef4\u62a4\u53ef\u8fd0\u884c\u4efb\u52a1&#xff0c;\u9009\u62e9\u4e0b\u4e00\u4e2a\u4efb\u52a1\u7684\u590d\u6742\u5ea6\u53d8\u6210 O(log n)&#xff0c;\u4f46\u516c\u5e73\u6027\u66f4\u597d\u3002\u66f4\u65b0\u7684\u5185\u6838\u4f7f\u7528 EEVDF\u3002\u4eca\u5929\u5728 ps \u6216 top \u91cc\u4ecd\u7136\u80fd\u770b\u5230 PRI \u548c NI&#xff0c;\u4f46\u80cc\u540e\u7684\u8c03\u5ea6\u5668\u5df2\u7ecf\u4e0d\u518d\u662f\u8fd9\u5957 140 \u4e2a\u961f\u5217\u7684\u6570\u7ec4\u3002\u5728 CFS \u91cc&#xff0c;nice \u4e3b\u8981\u6298\u7b97\u6210\u6743\u91cd&#xff0c;\u5f71\u54cd\u7684\u662f CPU \u4efd\u989d&#xff0c;\u800c\u4e0d\u662f O(1) \u90a3\u79cd\u56fa\u5b9a\u961f\u5217\u7684\u5148\u540e\u987a\u5e8f\u3002<\/p>\n<p>\u53ef\u4ee5\u628a O(1) \u8c03\u5ea6\u5668\u5f53\u4f5c\u4e00\u4e2a\u7ecf\u5178\u6837\u672c&#xff1a;\u5b83\u628a\u201c\u4f18\u5148\u7ea7\u5982\u4f55\u6620\u5c04\u5230\u961f\u5217\u201d\u201c\u5982\u4f55\u7528\u4f4d\u56fe\u5feb\u901f\u627e\u6700\u9ad8\u4f18\u5148\u7ea7\u201d\u201c\u5982\u4f55\u7528\u53cc\u6570\u7ec4\u5904\u7406\u65f6\u95f4\u7247\u201d\u8bb2\u5f97\u5f88\u76f4\u89c2\u3002\u7406\u89e3\u8fd9\u4e9b\u7ed3\u6784&#xff0c;\u518d\u53bb\u770b CFS \u7684\u7ea2\u9ed1\u6811&#xff0c;\u4f1a\u5bb9\u6613\u5f88\u591a\u3002CFS \u7684\u8bbe\u8ba1\u548c\u8c03\u5ea6\u6a21\u578b\u53ef\u4ee5\u53c2\u8003 \u5185\u6838\u8c03\u5ea6\u6587\u6863\u3002<\/p>\n<h2>\u516d\u3001\u628a\u4e09\u4ef6\u4e8b\u4e32\u8d77\u6765<\/h2>\n<p>\u73b0\u5728\u628a\u4f18\u5148\u7ea7\u3001\u8c03\u5ea6\u548c\u5207\u6362\u653e\u56de\u540c\u4e00\u6761\u65f6\u95f4\u7ebf\u4e0a&#xff1a;<\/p>\n<li>\u8fdb\u7a0b A \u6b63\u5728 CPU \u4e0a\u8fd0\u884c&#xff0c;\u5b83\u7684\u5bc4\u5b58\u5668\u73b0\u573a\u88c5\u5728 CPU \u91cc\u3002<\/li>\n<li>\u65f6\u949f\u4e2d\u65ad\u5230\u6765&#xff0c;A \u7684\u65f6\u95f4\u7247\u7528\u5b8c&#xff1b;\u6216\u8005 A \u963b\u585e&#xff0c;\u6216\u8005\u66f4\u9ad8\u4f18\u5148\u7ea7\u7684 B \u88ab\u5524\u9192\u3002<\/li>\n<li>\u5185\u6838\u8fdb\u5165\u8c03\u5ea6\u5668&#xff0c;\u5728\u5f53\u524d CPU \u7684 runqueue \u91cc\u627e\u4e0b\u4e00\u4e2a\u4efb\u52a1\u3002<\/li>\n<li>\u8c03\u5ea6\u5668\u901a\u8fc7\u4f4d\u56fe\u627e\u5230\u6700\u9ad8\u4f18\u5148\u7ea7\u7684\u975e\u7a7a\u961f\u5217&#xff0c;\u53d6\u51fa\u94fe\u8868\u5934\u7684 B\u3002<\/li>\n<li>\u5185\u6838\u4fdd\u5b58 A \u7684\u73b0\u573a&#xff0c;\u6062\u590d B \u7684\u73b0\u573a&#xff0c;\u8fd4\u56de\u7528\u6237\u6001&#xff1b;A \u8fdb\u5165\u8fc7\u671f\u961f\u5217\u6216\u7b49\u5f85\u961f\u5217\u3002<\/li>\n<p>\u4f18\u5148\u7ea7\u51b3\u5b9a A \u548c B \u5728\u961f\u5217\u91cc\u7684\u4f4d\u7f6e&#xff0c;\u8c03\u5ea6\u5668\u51b3\u5b9a\u8fd9\u6b21\u9009\u8c01&#xff0c;\u4e0a\u4e0b\u6587\u5207\u6362\u8d1f\u8d23\u628a CPU \u771f\u6b63\u4ea4\u51fa\u53bb\u3002\u4e09\u8005\u914d\u5408&#xff0c;\u624d\u6709\u4e86\u201c\u591a\u4e2a\u8fdb\u7a0b\u540c\u65f6\u63a8\u8fdb\u201d\u7684\u6548\u679c\u3002<\/p>\n<h2>\u4e03\u3001\u51e0\u4e2a\u5bb9\u6613\u6df7\u6dc6\u7684\u70b9<\/h2>\n<ul>\n<li>nice \u4e0d\u662f\u4f18\u5148\u7ea7\u672c\u8eab\u3002 nice \u662f\u4fee\u6b63\u503c&#xff0c;PRI \u662f\u663e\u793a\u503c&#xff0c;\u5185\u6838\u961f\u5217\u4e0b\u6807\u53c8\u662f\u53e6\u4e00\u5957\u523b\u5ea6&#xff0c;\u4e09\u8005\u65b9\u5411\u4e00\u81f4\u4f46\u6570\u503c\u4e0d\u540c\u3002<\/li>\n<li>\u4f18\u5148\u7ea7\u4e0d\u662f\u6743\u9650\u3002 \u9ad8\u4f18\u5148\u7ea7\u8fdb\u7a0b\u4e0d\u80fd\u7ed5\u8fc7\u6587\u4ef6\u6743\u9650&#xff0c;\u4f4e\u4f18\u5148\u7ea7 root \u8fdb\u7a0b\u4e5f\u4e0d\u4f1a\u56e0\u4e3a nice \u9ad8\u5c31\u5931\u53bb\u6743\u9650\u3002<\/li>\n<li>\u8fdb\u5165\u5185\u6838\u4e0d\u7b49\u4e8e\u53d1\u751f\u5207\u6362\u3002 \u7cfb\u7edf\u8c03\u7528\u548c\u4e2d\u65ad\u53ef\u80fd\u53ea\u662f\u5185\u6838\u5904\u7406\u5b8c\u518d\u8fd4\u56de\u539f\u4efb\u52a1&#xff1b;\u53ea\u6709\u9009\u4e2d\u53e6\u4e00\u4e2a\u4efb\u52a1\u624d\u9700\u8981\u4fdd\u5b58\u548c\u6062\u590d\u4e0a\u4e0b\u6587\u3002<\/li>\n<li>O(1) \u53ea\u63cf\u8ff0\u9009\u62e9\u4efb\u52a1\u7684\u590d\u6742\u5ea6\u3002 \u771f\u5b9e\u8c03\u5ea6\u4ecd\u6709\u9501\u3001\u7f13\u5b58\u548c\u8d1f\u8f7d\u5747\u8861\u7684\u5f00\u9500&#xff1b;\u73b0\u4ee3\u5185\u6838\u4e5f\u5df2\u7ecf\u6539\u7528 CFS \u548c EEVDF\u3002<\/li>\n<li>\u9ad8\u4f18\u5148\u7ea7\u4e0d\u7b49\u4e8e\u5b9e\u65f6\u3002 \u666e\u901a\u8fdb\u7a0b\u7684 nice \u8303\u56f4\u53ea\u6709 -20 \u5230 19&#xff0c;\u5b9e\u65f6\u4efb\u52a1\u662f\u53e6\u4e00\u5957\u8c03\u5ea6\u7b56\u7565\u548c\u4f18\u5148\u7ea7\u533a\u95f4\u3002<\/li>\n<\/ul>\n<p>END<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":122334,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58],"topic":[],"class_list":["post-122336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \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\/122336.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/122336.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-04T10:49:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104104903-6aeb0d9f6e227.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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122336.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/122336.html\",\"name\":\"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-04T10:49:09+00:00\",\"dateModified\":\"2026-11-04T10:49:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/122336.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/122336.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122336.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6\"}]},{\"@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":"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \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\/122336.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/122336.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-04T10:49:09+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104104903-6aeb0d9f6e227.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/122336.html","url":"https:\/\/www.wsisp.com\/helps\/122336.html","name":"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-04T10:49:09+00:00","dateModified":"2026-11-04T10:49:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/122336.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/122336.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/122336.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u8fdb\u7a0b\u4f18\u5148\u7ea7\u3001\u5207\u6362\u4e0e\u8c03\u5ea6"}]},{"@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\/122336","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=122336"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122336\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/122334"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=122336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=122336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=122336"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=122336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}