Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do you set processor affinity in Snow Leopard on a MacBook Pro?I know in Windows you could just switch it in Task Manager.

share|improve this question
1  
<snarky-comment>Run OS X in a virtual machine, and set the affinity of the virtual machine</snarky-comment> –  zildjohn01 Jun 6 '10 at 1:49
    
Why would you want to do this? It's generally a bad idea unless you're trying to get old programs running that are so badly coded they break on multicore systems. –  jalf Jun 6 '10 at 1:52
2  
@jalf: processor affinity can improve performance since it reduces cache invalidation & trashing in some cases. –  jweyrich Jun 6 '10 at 2:20
1  
That's disappointing. Looks like Mac will never be an ideal platform for real-time software development. –  Evan Plaice Feb 11 '11 at 0:11
    
@jweyrich Excepts in CPUs with QPI (Intel's NUMA) like those on the Mac Pro, where setting CPU affinity disables memory affinity and decreases performance. This does not apply to mobile processors though. –  Jano Aug 29 '12 at 21:50
add comment

migrated from stackoverflow.com Jun 6 '10 at 6:38

This question came from our site for professional and enthusiast programmers.

3 Answers

http://developer.apple.com/mac/library/releasenotes/Performance/RN-AffinityAPI/

Mac OS X does not export interfaces that identify processors or control thread placement—explicit thread to processor binding is not supported. Instead, the kernel manages all thread placement. Applications expect that the scheduler will, under most circumstances, run its threads using a good processor placement with respect to cache affinity.

share|improve this answer
add comment

Until now, the XNU (1504.3.12) scheduler doesn't implement processor affinity for processes nor threads.

So MacOSX doesn't provide any means to do that.

share|improve this answer
add comment

From http://images.apple.com/macosx/docs/OSX_for_UNIX_Users_TB_July2011.pdf

• Efficient kernel threads. Each POSIX thread is queued onto a particular CPU, improving processor affinity and scalability while reducing lock contention. Threads conform to POSIX (1c), including support for cancellation and shared mutexes.

It looks like ad to me, my iMac running Lion looks to respect that most of the time, but it do not 'pin'a process to a core.

I could not find any API to control process affinity for darwin anyway.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.