LDD: Multi-core affinity

Source: Internet
Author: User

1, process binding

#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, Thread binding

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, Kernel State

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

4, command-line binding

Taskset-p <COREMASK> <PID>

TASKSET-CP <CORE-LIST> <PID>

5, Interrupt bind core:

Echo 0x3/proc/irq/24/smp_affinity

Cat/proc/irq/24/smp_affinity

LDD: Multi-core affinity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.