• 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
sysctlbyname( "hw.availcpu" ) fails
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sysctlbyname( "hw.availcpu" ) fails


  • Subject: sysctlbyname( "hw.availcpu" ) fails
  • From: Steve Checkoway <email@hidden>
  • Date: Sat, 23 Jun 2007 04:38:39 -0700

When I try to use sysctlbyname with "hw.availcpu", I get an error but when I use { CTL_HW, HW_AVAILCPU } with sysctl, it succeeds. Here is my test case:

#include <sys/types.h>
#include <sys/sysctl.h>
#include <stdio.h>

int main()
{
        int mib[2] = { CTL_HW, HW_AVAILCPU };
        int cpus;
        size_t size = sizeof( cpus );

        if( sysctl(mib, 2, &cpus, &size, NULL, 0) == -1 )
                perror( "sysctl" );
        else
                printf( "sysctl: %d\n", cpus );
        size = sizeof( cpus );
        if( sysctlbyname("hw.availcpu", &cpus, &size, NULL, 0) == -1 )
                perror( "sysctlbyname" );
        else
                printf( "sysctlbyname: %d\n", cpus );
        size = 2;
        if( sysctlnametomib("hw.availcpu", mib, &size) == -1 )
                perror( "sysctlnametomib" );
        size = sizeof( cpus );
        if( sysctl(mib, 2, &cpus, &size, NULL, 0) )
                perror( "sysctl2" );
        else
                printf( "sysctl2: %d\n", cpus );
        return 0;
}

When I run it, I get:
$ ./a.out
sysctl: 2
sysctlbyname: No such file or directory
sysctlnametomib: No such file or directory
sysctl2: 2
$ sysctl hw.availcpu hw.activecpu
hw.availcpu = 2
hw.activecpu: 2

What is the difference between activecpu and availcpu, e.g., why does one have an equal sign and the other a colon?

A similar issue I found in the list archives was <http:// lists.apple.com/archives/darwin-development/2003/Aug/msg00256.html>.

Just to be clear about this, I only want the information for my own debugging purposes. Absolutely nothing in the code makes any decisions based on the number of cpus.

--
Steve Checkoway




Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: sysctlbyname( "hw.availcpu" ) fails
      • From: Terry Lambert <email@hidden>
  • Prev by Date: Re: size of "disk cache"
  • Next by Date: Where can I find a comprehensive manual for the openfirmware of Mac?
  • Previous by thread: Re: size of "disk cache"
  • Next by thread: Re: sysctlbyname( "hw.availcpu" ) fails
  • Index(es):
    • Date
    • Thread