{"id":8457,"date":"2020-07-28T20:37:52","date_gmt":"2020-07-28T12:37:52","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=8457"},"modified":"2020-07-28T20:37:53","modified_gmt":"2020-07-28T12:37:53","slug":"taskset","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/taskset","title":{"rendered":"taskset\u547d\u4ee4 – \u8bbe\u7f6e\u6216\u68c0\u7d22\u8fdb\u7a0b\u7684CPU\u76f8\u5173\u6027"},"content":{"rendered":"\n

\u5c06\u8fdb\u7a0b\u7ed1\u5b9a\u5230\u6307\u5b9a\u7684CPU\u4e0a\u8fd0\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5927\u91cf\u7684\u8fdb\u7a0b\u5207\u6362\u4ea7\u751f\u7684\u65e0\u6548\u65f6\u95f4\u3002\u901a\u8fc7 taskset \u547d\u4ee4\u53ef\u5c06\u67d0\u4e2a\u8fdb\u7a0b\u4e0e\u67d0\u4e2aCPU\u6838\u5fc3\u7ed1\u5b9a\uff0c\u4f7f\u5f97\u5176\u4ec5\u5728\u4e0e\u4e4b\u7ed1\u5b9a\u7684CPU\u6838\u5fc3\u4e0a\u8fd0\u884c\u3002<\/p>\n\n\n\n

\u7ebf\u7a0b\u662f\u6700\u5c0f\u7684\u5185\u6838\u6267\u884c\u8c03\u5ea6\u5355\u5143\uff0c\u56e0\u6b64\uff0c\u51c6\u786e\u5730\u8bf4\u662f\u5c06\u67d0\u4e2a\u7ebf\u7a0b\u4e0e\u67d0\u4e2aCPU\u6838\u5fc3\u7ed1\u5b9a\uff0c\u800c\u975e\u67d0\u4e2a\u8fdb\u7a0b\u3002<\/p>\n\n\n\n

taskset\u547d\u4ee4\u662f\u4f9d\u636e\u7ebf\u7a0bPID\uff08TID\uff09\u67e5\u8be2\u6216\u8bbe\u7f6e\u7ebf\u7a0b\u7684CPU\u4eb2\u548c\u6027\uff08\u4e0e\u54ea\u4e2aCPU\u6838\u5fc3\u7ed1\u5b9a\uff09\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>taskset [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

-a, --all-tasks<\/td>\u8bbe\u7f6e\u6216\u68c0\u7d22\u6240\u6709\u4efb\u52a1\uff08\u7ebf\u7a0b\uff09\u7684CPU\u76f8\u5173\u6027\u5bf9\u4e8e\u7ed9\u5b9a\u7684PID<\/td><\/tr>
-c, --cpu-list<\/td>\u5c06\u63a9\u7801\u89e3\u91ca\u4e3a\u5904\u7406\u5668\u7684\u6570\u5b57\u5217\u8868<\/td><\/tr>
-p, --pid<\/td>\u5728\u73b0\u6709PID\u4e0a\u64cd\u4f5c\uff0c\u4e0d\u8981\u542f\u52a8\u65b0\u4efb\u52a1<\/td><\/tr>
-V, --version<\/td>\u663e\u793a\u7248\u672c\u4fe1\u606f<\/td><\/tr>

-h, --help<\/td>
\u663e\u793a\u5e2e\u52a9\u4fe1\u606f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u4f7f\u7528\u7ed9\u5b9a\u7684\u5173\u8054\u8fd0\u884c\u65b0\u547d\u4ee4\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# taskset mask command [arguments]<\/pre>\n\n\n\n

\u68c0\u7d22\u73b0\u6709\u4efb\u52a1\u7684CPU\u76f8\u5173\u6027\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# taskset -p pid<\/pre>\n\n\n\n

\u8bbe\u7f6e\u73b0\u6709\u4efb\u52a1\u7684CPU\u76f8\u5173\u6027\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# taskset -p mask pid<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u5c06\u8fdb\u7a0b\u7ed1\u5b9a\u5230\u6307\u5b9a\u7684CPU\u4e0a\u8fd0\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5927\u91cf\u7684\u8fdb\u7a0b\u5207\u6362\u4ea7\u751f\u7684\u65e0\u6548\u65f6\u95f4\u3002\u901a\u8fc7 taskset \u547d\u4ee4\u53ef\u5c06\u67d0\u4e2a\u8fdb […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8457"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=8457"}],"version-history":[{"count":1,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8457\/revisions"}],"predecessor-version":[{"id":8458,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/8457\/revisions\/8458"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=8457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=8457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=8457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}