CPU affinity

Anthony

Registered
On a multi-processor Windows NT based machine you can bring up task manager, look at the list of running processes, right click and use the "Set Affinity" option to tell which processes to use which CPU. I'm wondering if there is something equivalent on OS X so that I could force certain processes to use certain CPUs and override the automatic threading/affinity. Any ideas? Or is it not even possible on the Darwin kernel?
 
I've already looked that over but can't find anything to do with affinity.. it doesn't even display information related to which CPU is doing what other than the overall load on each. I also noticed the unix command "pset" is missing from Unix side that would normally let you set the affinity, so I'm thinking maybe Darwin doesn't support on-the-fly changes in this manner. (Its entirely possible, I don't think Linux supports it either without special kernel hacks.)
 
isn't this also called "nice"? like, you can re-nice a process to allot more cpu? maybe i'm wrong.
 
Its not the same thing as nice. CPU affinity means selecting WHICH cpu does which thread. Its only something you consider on multiple-cpu machines. Nice changes the priority of a PROCESS. Processes are made up of one or more threads. Affinity is which physical CPU processes which thread. The system kernel automatically distributes threads across multiple CPUs but sometimes it doesn't do the most efficient job.

For example if I'm encoding a large video file (which is something I do quite often, the main reason I'm trying to figure out if this is possible), I could have a thread running for literally 10-20 hours. The thread is assigned to a CPU at the beginning of the task, which might make sense at the time... but after many hours depending on what else I'm doing on my machine it might not make sense to still be running it on that CPU. Its a nerdy nit-picky thing, but it would just be nice to be able to shuffle things around so that I'm getting the most out of the machine when I'm running these really long and intensive tasks.
 
in that case, an alternate solution might be to take a look at apples xGrid app. if you have multiple macs, it might make sense to let the large time-intensive task be distributed to other machines on your network.though, i suppose if you had a mac sitting around, you wouldn't be asking this question.
 
Its not the same thing as nice. CPU affinity means selecting WHICH cpu does which thread. Its only something you consider on multiple-cpu machines. Nice changes the priority of a PROCESS. Processes are made up of one or more threads. Affinity is which physical CPU processes which thread. The system kernel automatically distributes threads across multiple CPUs but sometimes it doesn't do the most efficient job.

For example if I'm encoding a large video file (which is something I do quite often, the main reason I'm trying to figure out if this is possible), I could have a thread running for literally 10-20 hours. The thread is assigned to a CPU at the beginning of the task, which might make sense at the time... but after many hours depending on what else I'm doing on my machine it might not make sense to still be running it on that CPU. Its a nerdy nit-picky thing, but it would just be nice to be able to shuffle things around so that I'm getting the most out of the machine when I'm running these really long and intensive tasks.

It looks like that you're looking for taskset.

Apparently, from the looks of it; that is NOT available in OS X. And also according to this source, it says that the FreeBSD version of that is cpuset.

Otherwise, it doesn't look like that it's possible at all.

I wonder if you can actually just download the source code for taskset/cpuset and then compile it for OS X. Hmmm...weird.
 
Back
Top