what you are talking about is called setting cpu affinity. in linux you use the tool 'taskset' which makes things very easy, there are a few freebsd equivalents that claim compatibility with open-darwin. but looking at other responses it looks like they provide thread or process affinity.
if you search for 'os x cpu affinity' you will find lots of hits, but not many promising leads i am afraid.
there are api calls for this too, if you wanted to write the thing yourself.
but try taskset and cpuset, they're your best bet.