多核和親和性
阿新 • • 發佈:2019-01-30
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,proc繫結
echo 0x3 /proc/irq/24/smp_affinity
cat /proc/irq/24/smp_affinity