| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
#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
-- 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: http://lists.apple.com/mailman/options/darwin-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.