O OS X tem suporte para uma API de afinidade de encadeamento desde a versão 10.5. Aqui está algum material relevante da página da Web a que me vinculei.
Conjunto de afinidades
An affinity set is a collection of threads which share memory resources and wish to share an L2 cache. Distinct affinity sets represent separate affinities—that is, threads belonging to a different set should use a separate L2 cache and hence be run on a different logical processors.
An affinity set is identified by a "tag". Threads are assigned to a particular affinity set by assigning it the tag identifying that set. A thread can belong to at most one affinity set; that is, it has one affinity tag.
Efeito da configuração de tags de afinidade distintas
For example, an application wanting to run 2 threads on separate L2 caches would set the threads with different affinity tags. On a dual core machine, this affinity will effectively be ignored. However, on a 4-core MacPro, the scheduler will try to run threads on separate packages. Similarly, on an 8-core MacPro, the scheduler will try to run these threads on separate dies (which may or may not be in the same physical CPU package).
Exemplo de uso
An application that wants to place a thread on every available processor would do the following:
- Obtain the number of processors on the system using sysctl(3).
- Create that number of threads.
- Set each thread with a distinct affinity tag.
- Start all threads.
Threads with default affinity policy will be scheduled more freely on any processor. These threads will be preferentially migrated to run on an idle processor. Threads with affinity tags will tend to remain in place.
Consulte a origem das listagens de código e as informações sobre o compartilhamento de tags de afinidade entre os processos pai e filho, obtendo a configuração do cache da CPU e muito mais.