• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the number of CPUs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the number of CPUs?


  • Subject: Re: Getting the number of CPUs?
  • From: Stéphane Sudre <email@hidden>
  • Date: Tue, 7 Aug 2001 20:02:56 +0200

On mardi, ao{t 7, 2001, at 07:52 PM, Ken Tabb wrote:

Hi,
is there any Cocoa-y way of getting the number of CPUs on the host? I'm
aiming to use this as part of a thread-spawning decision process (so that
a single processor machine doesn't get twice as many threads as it needs
to do the job).

I don't know but I'm using this:

#include <mach/mach.h>
#include <mach/bootstrap.h>
#include <mach/mach_error.h>

kern_return_t error;
mach_port_t host_control, device, wledger, pledger, security;
processor_array_t tArray;
mach_msg_type_number_t tProcNumber;
mach_msg_type_number_t i;

error = bootstrap_ports(mach_task_self(), &host_control, &device,
&wledger, &pledger, &security);

if (error != KERN_SUCCESS) {
mach_error("bootstrap_ports", error);
}

error=host_processors(host_control,&tArray,&tProcNumber);

if (error == KERN_SUCCESS)
{

CPUNumber_=tProcNumber;

}
else
{
mach_error("host_processors", error);
}
return self;


  • Prev by Date: Getting the number of CPUs?
  • Next by Date: Re: Admin programs and password
  • Previous by thread: Getting the number of CPUs?
  • Next by thread: Re: Getting the number of CPUs?
  • Index(es):
    • Date
    • Thread