linux 下设置进程在多核间调度

函数里设置:

sched_setaffinity(getpid(), sizeof(core_mask), &core_mask)

例:

core_mask为掩码如

1100 在3、4核上调度

0100 仅在3核上

 

shell下指定进程使用的cpu:
taskset -p COREMASK  PID

 

查看进程所在cpu、以及cpu占用率:

sudo htop

你可能感兴趣的:(linux,shell)