#!/bin/bash
# Set CPU affinity for process
taskset -c 0,1,2,3 ./my_program
// Set CPU affinity for thread
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
// Set CPU affinity for process using percpu variable
cpumask_t mask;
cpumask_clear(&mask);
cpumask_set_cpu(0, &mask);
cpumask_set_cpu(1, &mask);
cpumask_set_cpu(2, &mask);
cpumask_set_cpu(3, &mask);
set_cpus_allowed_ptr(current, &mask);