Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Bind a process to a CPU using the taskset command

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Taskset (util-linux-ng 2.17.2) usage: taskset [options] [mask | cpu-list] [pid | cmd [args...]] set or get the affinity of a process-p,-- pid operate on existing given pid-c,-- cpu-list display and specify cpus in list format-h,-- help display this help-V -- version output version informationThe default behavior is to run a new command: taskset 03 sshd-b 1024You can retrieve the mask of an existing task: taskset-p 700Or set it: taskset-p 03 700List format uses a comma-separated list instead of a mask: taskset-pc 0 3 7-11 700Ranges in list format can take a stride argument: e.g. 0-31:2 is equivalent to mask 0x55555555

Example:

Bind the process with pid number 2181 to cpu0:

[root@Centos] # taskset-cp 0 2181pid 2181s current affinity list: 0pid 2181s new affinity list: 0

Bind the process with pid number 2181 to several cpu:

[root@Centos ~] # taskset-cp 0Power1 2181-bind to cpu0 and cpu1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report