image
image

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

Reply
 
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
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 10,369
Thanks: 3
Thanked 124 Times in 113 Posts
ElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the rough
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?
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
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
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 10,369
Thanks: 3
Thanked 124 Times in 113 Posts
ElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the rough
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/
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
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
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 10,369
Thanks: 3
Thanked 124 Times in 113 Posts
ElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the rough
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.
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
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,505
Thanks: 4
Thanked 15 Times in 14 Posts
Mikuro is on a distinguished road
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.5

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

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 02:30 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.