如何利用taskset命令,將某進(jìn)程綁定到某個(gè)CPU上
發(fā)布時(shí)間:2020-04-09 點(diǎn)擊數(shù):1462
如何利用taskset命令,將某進(jìn)程綁定到某個(gè)CPU上呢?接下來(lái)就給大家分享一下。
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 information
The default behavior is to run a new command:
taskset 03 sshd -b 1024
You can retrieve the mask of an existing task:
taskset -p 700
Or set it:
taskset -p 03 700
List format uses a comma-separated list instead of a mask:
taskset -pc 0,3,7-11 700
Ranges in list format can take a stride argument:
e.g. 0-31:2 is equivalent to mask 0x55555555
例:
將pid號(hào)為2181的進(jìn)程綁定到cpu0上:
[root@Centos ~]# taskset -cp 0 2181
pid 2181's current affinity list: 0
pid 2181's new affinity list: 0
將pid號(hào)為2181的進(jìn)程綁定到幾個(gè)cpu上:
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 information
The default behavior is to run a new command:
taskset 03 sshd -b 1024
You can retrieve the mask of an existing task:
taskset -p 700
Or set it:
taskset -p 03 700
List format uses a comma-separated list instead of a mask:
taskset -pc 0,3,7-11 700
Ranges in list format can take a stride argument:
e.g. 0-31:2 is equivalent to mask 0x55555555
例:
將pid號(hào)為2181的進(jìn)程綁定到cpu0上:
[root@Centos ~]# taskset -cp 0 2181
pid 2181's current affinity list: 0
pid 2181's new affinity list: 0
將pid號(hào)為2181的進(jìn)程綁定到幾個(gè)cpu上:
[root@Centos ~]# taskset -cp 0,1 2181 --綁定到cpu0和cpu1上
以上是全網(wǎng)數(shù)據(jù)小編的分享,全網(wǎng)數(shù)據(jù)為大家提供專(zhuān)業(yè)化深圳服務(wù)器托管,深圳服務(wù)器租用,深圳主機(jī)托管,云服務(wù)租用等服務(wù)器資源,詳情歡迎咨詢客服了解。