多核亲和性

1,进程绑定

#include <sched.h> 
cpu_set_t  set;
void CPU_ZERO(cpu_set_t *set);
void CPU_SET(int cpu, cpu_set_t *set);
void CPU_CLR(int cpu, cpu_set_t *set);
int CPU_ISSET(int cpu, cpu_set_t *set);

int sched_setaffinity(pid_t pid, size_t cpusetsize,cpu_set_t *mask);   
int sched_getaffinity(pid_t pid, size_t cpusetsize,cpu_set_t *mask);   

 

2,线程绑定

int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, const cpu_set_t *cpuset);
int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t *cpuset);

 

3,内核态

void kthread_bind (struct task_struct *k, unsigned int  cpu);
int set_cpus_allowed(struct task_struct *k, cpumask_t new_mask);

 

4,命令行绑定

taskset -p <COREMASK>  <PID>

taskset -cp <CORE-LIST>  <PID> 

 

5,中断绑核:

echo 0x3 /proc/irq/24/smp_affinity

cat /proc/irq/24/smp_affinity

 

posted @ 2016-12-04 14:01  soul.stone  阅读(422)  评论(0编辑  收藏  举报