1CPU_SET(3) Linux Programmer's Manual CPU_SET(3)
2
3
4
6 CPU_SET, CPU_CLR, CPU_ISSET, CPU_ZERO, CPU_COUNT, CPU_AND, CPU_OR,
7 CPU_XOR, CPU_EQUAL, CPU_ALLOC, CPU_ALLOC_SIZE, CPU_FREE, CPU_SET_S,
8 CPU_CLR_S, CPU_ISSET_S, CPU_ZERO_S, CPU_COUNT_S, CPU_AND_S, CPU_OR_S,
9 CPU_XOR_S, CPU_EQUAL_S - macros for manipulating CPU sets
10
12 #define _GNU_SOURCE /* See feature_test_macros(7) */
13 #include <sched.h>
14
15 void CPU_ZERO(cpu_set_t *set);
16
17 void CPU_SET(int cpu, cpu_set_t *set);
18 void CPU_CLR(int cpu, cpu_set_t *set);
19 int CPU_ISSET(int cpu, cpu_set_t *set);
20
21 int CPU_COUNT(cpu_set_t *set);
22
23 void CPU_AND(cpu_set_t *destset,
24 cpu_set_t *srcset1, cpu_set_t *srcset2);
25 void CPU_OR(cpu_set_t *destset,
26 cpu_set_t *srcset1, cpu_set_t *srcset2);
27 void CPU_XOR(cpu_set_t *destset,
28 cpu_set_t *srcset1, cpu_set_t *srcset2);
29
30 int CPU_EQUAL(cpu_set_t *set1, cpu_set_t *set2);
31
32 cpu_set_t *CPU_ALLOC(int num_cpus);
33 void CPU_FREE(cpu_set_t *set);
34 size_t CPU_ALLOC_SIZE(int num_cpus);
35
36 void CPU_ZERO_S(size_t setsize, cpu_set_t *set);
37
38 void CPU_SET_S(int cpu, size_t setsize, cpu_set_t *set);
39 void CPU_CLR_S(int cpu, size_t setsize, cpu_set_t *set);
40 int CPU_ISSET_S(int cpu, size_t setsize, cpu_set_t *set);
41
42 int CPU_COUNT_S(size_t setsize, cpu_set_t *set);
43
44 void CPU_AND_S(size_t setsize, cpu_set_t *destset,
45 cpu_set_t *srcset1, cpu_set_t *srcset2);
46 void CPU_OR_S(size_t setsize, cpu_set_t *destset,
47 cpu_set_t *srcset1, cpu_set_t *srcset2);
48 void CPU_XOR_S(size_t setsize, cpu_set_t *destset,
49 cpu_set_t *srcset1, cpu_set_t *srcset2);
50
51 int CPU_EQUAL_S(size_t setsize, cpu_set_t *set1, cpu_set_t *set2);
52
54 The cpu_set_t data structure represents a set of CPUs. CPU sets are
55 used by sched_setaffinity(2) and similar interfaces.
56
57 The cpu_set_t data type is implemented as a bit mask. However, the
58 data structure should be treated as opaque: all manipulation of CPU
59 sets should be done via the macros described in this page.
60
61 The following macros are provided to operate on the CPU set set:
62
63 CPU_ZERO() Clears set, so that it contains no CPUs.
64
65 CPU_SET() Add CPU cpu to set.
66
67 CPU_CLR() Remove CPU cpu from set.
68
69 CPU_ISSET() Test to see if CPU cpu is a member of set.
70
71 CPU_COUNT() Return the number of CPUs in set.
72
73 Where a cpu argument is specified, it should not produce side effects,
74 since the above macros may evaluate the argument more than once.
75
76 The first CPU on the system corresponds to a cpu value of 0, the next
77 CPU corresponds to a cpu value of 1, and so on. No assumptions should
78 be made about particular CPUs being available, or the set of CPUs being
79 contiguous, since CPUs can be taken offline dynamically or be otherwise
80 absent. The constant CPU_SETSIZE (currently 1024) specifies a value
81 one greater than the maximum CPU number that can be stored in
82 cpu_set_t.
83
84 The following macros perform logical operations on CPU sets:
85
86 CPU_AND() Store the intersection of the sets srcset1 and srcset2
87 in destset (which may be one of the s