# 将 11282 进程绑定到CPU第0核心 [test1280@localhost ~]$ ps -Lf 11282 UID PID PPID LWP C NLWP STIME TTY STAT TIME CMD test1280 11282 9374 11282 0 4 11:33 pts/0 Sl+ 0:00 ./main test1280 11282 9374 11283 0 4 11:33 pts/0 Sl+ 0:00 ./main test1280 11282 9374 11284 0 4 11:33 pts/0 Sl+ 0:00 ./main test1280 11282 9374 11285 0 4 11:33 pts/0 Sl+ 0:00 ./main [test1280@localhost ~]$ taskset -pc 0 11282 pid 11282's current affinity list: 0-3 pid 11282's new affinity list: 0 # 查看其他线程是否真的绑定到CPU第0核心 [test1280@localhost ~]$ taskset -pc 11283 pid 11283's current affinity list: 0-3 [test1280@localhost ~]$ taskset -pc 11284 pid 11284's current affinity list: 0-3 [test1280@localhost ~]$ taskset -pc 11285 pid 11285's current affinity list: 0-3 [test1280@localhost ~]$ taskset -pc 11282 pid 11282's current affinity list: 0 # 此时实际只绑定主线程到CPU第0核心 # 将其他四个线程一并绑定到CPU第0核心 [test1280@localhost ~]$ taskset -pc 0 11283 pid 11283's current affinity list: 0-3 pid 11283's new affinity list: 0 [test1280@localhost ~]$ taskset -pc 0 11284 pid 11284's current affinity list: 0-3 pid 11284's new affinity list: 0 [test1280@localhost ~]$ taskset -pc 0 11285 pid 11285's current affinity list: 0-3 pid 11285's new affinity list: 0 # 此时,进程PID=11282的进程所有线程都将仅在CPU第0核心中运行