image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
LinkBack Thread Tools
  #1  
Old August 19th, 2008, 06:48 PM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
JGFoster is on a distinguished road
How to set CPU affinity (taskset)?

I understand that Leopard has more sophisticated processor affinity capabilities and I am wondering if there is a way to get to that from a C-level API (and from the command line).

The reason I want this is to limit the functionality of a free version of a product (e.g., Oracle Express Edition and and Microsoft SQL Server Express Edition) so that it runs on only one CPU, no matter how many are on the machine. This way we can let developers use the real product for development and small projects, but we can charge when scaling is needed.

James
Reply With Quote
  #2  
Old August 19th, 2008, 08:37 PM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 12,672
Thanks: 7
Thanked 388 Times in 370 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
As far as I know, Microsoft SQL Server Express Edition does not run on Mac OS X.

Are you running Mac OS X or Windows on your Mac computer?
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 18Mb/2Mb
http://www.jeffhoppe.com
Reply With Quote
  #3  
Old August 19th, 2008, 11:00 PM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
JGFoster is on a distinguished road
Is there a way to set CPU affinity on Mac OSX 10.5?

I am not trying to run SQL Server on Mac OSX. I am trying to set CPU affinity using a C API for a competing product that has a similar licensing model but runs on Macintosh OSX 10.5.
Reply With Quote
  #4  
Old August 20th, 2008, 09:04 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 12,672
Thanks: 7
Thanked 388 Times in 370 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
Ah, I see... Apple has a few APIs that can help out with thread affinity, but I don't know whether you can set a process to only run on one core or another.

http://developer.apple.com/releaseno...N-AffinityAPI/
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 18Mb/2Mb
http://www.jeffhoppe.com
Reply With Quote
The Following User Says Thank You to ElDiabloConCaca For This Useful Post:
JGFoster (August 20th, 2008)
  #5  
Old August 20th, 2008, 10:45 AM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
JGFoster is on a distinguished road
The release notes were helpful and come close to what I need. Thread affinity (as opposed to process affinity) would be fine. The only problem I see is in the notes where it says "Threads with affinity tags will tend to remain in place" (emphasis added). Since my goal is actually performance degradation(!), I wonder if the OS will move threads if my preferred CPU is busy.
Reply With Quote
  #6  
Old August 20th, 2008, 11:45 AM
ElDiabloConCaca's Avatar
Registered User
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 12,672
Thanks: 7
Thanked 388 Times in 370 Posts
ElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of lightElDiabloConCaca is a glorious beacon of light
It's possible, but I don't know enough about Mac OS X's thread/processor management to say one way or the other.

I know what you're talking about on the Windows-side, though -- with the ability to "tell" a certain process to only use Core 1, or Processor 2, or the like. I think since Mac OS X is a much more heavily threaded operating system with a different way of managing processes that the kind of control you're looking for may not exist, or may be managed in a completely different way, without control over specific processors or cores.
__________________
Mac mini 2.0GHz 10.6.2 • 4GB • 320GB • Superdrive • 4 x 1TB USB 2.0 • LED Cinema Display
MacBook 2.0GHz Core 2 Duo - White 10.6.2 • 4GB • 250GB • CD-RW/DVD-ROM
iPhone 3G 8GB • iPod Touch 8GB • iPod Photo 60GB • iPod nano 1GB • AT&T U-Verse 18Mb/2Mb
http://www.jeffhoppe.com
Reply With Quote
  #7  
Old August 20th, 2008, 04:58 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,682
Thanks: 6
Thanked 53 Times in 48 Posts
Mikuro will become famous soon enough
Would it be possible to have the limited version of your program only use one thread? If you did, it would effectively limit the program to one core, since OS X can't split a single thread across two cores.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #8  
Old August 20th, 2008, 08:55 PM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
JGFoster is on a distinguished road
Quote:
Originally Posted by Mikuro View Post
Would it be possible to have the limited version of your program only use one thread?
No. The application (an enterprise object database) at a minimum runs a dozen processes, each of which can have multiple threads. The idea is to run the exact same software that is used by existing customers (who currently run thousands of processes across hundreds of machines). We can set CPU affinity on Linux, so have an easy way to license a free version with confidence that customers will contact us when they need to scale their application.
Reply With Quote
Reply

Bookmarks

Tags
leopard cpu affinity

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 08:59 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC1
Copyright 2000-2010 DigitalCrowd, Inc.