You can do this from bash. There is a wonderful taskset
command I acquainted in this question (you may also find valuable discussion on how scheduler should operate there). The command takes a pid of a process and binds it to the specific processor(s).
taskset -c 0 -p PID
binds the process with PID to processor (core) number 0.
What does it have to do with threads? To each thread is assigned an identifier with the same rights as pid, also known as "tid". You can get it with gettid
syscall. Or you can watch it, for example, in top
program by pressing H (some processes will split to many seemingly equal entries with different pids---those are threads).