Btw, what exactly did you not like about taskset? Let’s say I have four cpus. If I give each cpu a binary mask, I get something like this (just for fun, I start counting from cpu1, even though normally counting starts at cpu0):
Code:
CPU# MASK DECIMAL
cpu1 0001 1
cpu2 0010 2
cpu3 0100 4
cpu4 1000 8
What if I want a process to have affinity only for cpu1 and cpu4? I would OR the masks together for their combined mask:
Code:
cpu1 | cpu4 =
0001 | 1000 = 1001
= 9
So let’s say this process whose affinity I’m setting has pid 1234. I would do something like this to limit its affinity to cpu1 and cpu4:
Code:
# taskset -p 9 1234
(NOTE: it is somewhat strange that the PID does not immediately follow the “-p” flag.)